Java源码示例:org.apache.ws.commons.schema.XmlSchemaCollection
示例1
@BeforeClass
public static void setupClass() throws XmlSchemaSerializer.XmlSchemaSerializerException {
if (sourceSchemas == null) {
final InputSource inputSource = new InputSource(AbstractXmlSchemaExtractorTest.class
.getResourceAsStream(TEST_SCHEMA));
final XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
schemaCollection.read(inputSource);
sourceSchemas = new SchemaCollection(schemaCollection);
sourceSchemaNodes = new HashMap<>();
for (XmlSchema schema : sourceSchemas.getXmlSchemas()) {
final NodeList childNodes = schema.getSchemaDocument().getDocumentElement().getChildNodes();
List<Element> elements = new ArrayList<>();
for (int i = 0; i < childNodes.getLength(); i++) {
final Node node = childNodes.item(i);
if (node instanceof Element) {
elements.add((Element) node);
}
}
sourceSchemaNodes.put(schema.getTargetNamespace(), elements);
}
}
}
示例2
@Test
public void testAegisTypeSchema() throws Exception {
AegisContext context = new AegisContext();
context.initialize();
XmlSchemaCollection collection = new XmlSchemaCollection();
context.addTypesSchemaDocument(collection);
XmlSchema[] schemas = collection.getXmlSchemas();
XmlSchema typeSchema = null;
for (XmlSchema schema : schemas) {
if (AegisContext.UTILITY_TYPES_SCHEMA_NS.equals(schema.getTargetNamespace())) {
typeSchema = schema;
break;
}
}
assertNotNull(typeSchema);
assertNotSame(0, typeSchema.getItems().size());
XmlSchemaSerializer serializer = new XmlSchemaSerializer();
Document[] docs = serializer.serializeSchema(typeSchema, false);
testUtilities.assertValid("/xsd:schema/xsd:simpleType[@name='char']", docs[0]);
}
示例3
/**
* Create an empty XML Schema.
* <p/>
* If no targetNamespace, make sure there is no default namespace otherwise
* our complex types would be considered part of that default namespace
* (usually XML Schema namespace).
*
* @param encoding the character set used to encode this XML Schema
* @param targetNamespace the target namespace to use (null for no namespace)
* @return a new empty XML schema using the model
*/
protected XmlSchema createXmlSchema(final String encoding, final String targetNamespace) {
XmlSchema xsd = new XmlSchema(targetNamespace,
new XmlSchemaCollection());
if (targetNamespace != null) {
xsd.setElementFormDefault(XmlSchemaForm.QUALIFIED);
}
xsd.setAttributeFormDefault(null);
xsd.setInputEncoding(encoding);
if (targetNamespace == null) {
NamespaceMap prefixmap = new NamespaceMap();
NamespacePrefixList npl = xsd.getNamespaceContext();
if (npl == null) {
prefixmap.add("xsd", XMLConstants.W3C_XML_SCHEMA_NS_URI);
} else {
for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
String prefix = npl.getDeclaredPrefixes()[i];
String namespace = npl.getNamespaceURI(prefix);
if (namespace.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
if (prefix.equals("")) {
prefix = "xsd";
}
}
prefixmap.add(prefix, namespace);
}
}
xsd.setNamespaceContext(prefixmap);
}
return xsd;
}
示例4
/**
* @return an empty XML schema for testing
*/
public XmlSchema getXmlSchema() {
XmlSchema xsd = new XmlSchema("http://legstar.com/test",
new XmlSchemaCollection());
xsd.setElementFormDefault(XmlSchemaForm.QUALIFIED);
return xsd;
}
示例5
private String build(String schemaName) throws Exception {
File xsdFile = new File(TEST_XSD_FOLDER, schemaName + ".xsd");
Reader reader = new InputStreamReader(new FileInputStream(xsdFile),
LEGSTAR_XSD_FILE_ENCODING);
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema xsd = schemaCol.read(new StreamSource(reader));
Xsd2CobolTypesModelBuilder builder = new Xsd2CobolTypesModelBuilder();
Map < String, Xsd2CobolTypesModelBuilder.RootCompositeType > model = builder.build(xsd);
assertEquals(1, model.size());
return model.toString();
}
示例6
public TypesVisitorBase(XmlSchemaCollection xmlSchemas,
XmlSchema xmlSchema,
TypeMappingType typeMapRef) {
schemas = xmlSchemas;
schema = xmlSchema;
typeMap = typeMapRef;
}
示例7
protected static boolean findNonSchemaType(String name,
WSDLASTVisitor wsdlVisitor,
VisitorTypeHolder holder) {
boolean result = false;
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
QName qname = new QName(typeMap.getTargetNamespace(), name);
CorbaType corbaType = findCorbaType(typeMap, qname);
if (corbaType != null) {
if (corbaType instanceof Alias) {
result = true;
if (holder != null) {
populateAliasSchemaType(corbaType, wsdlVisitor, holder);
}
} else if (((corbaType instanceof Sequence) || (corbaType instanceof Anonsequence))
&& ((corbaType.getType().equals(Constants.XSD_BASE64)))) {
//special case of sequence of octets
result = true;
if (holder != null) {
holder.setCorbaType(corbaType);
holder.setSchemaType(schemas.getTypeByQName(corbaType.getType()));
}
}
}
return result;
}
示例8
protected static void populateAliasSchemaType(CorbaType corbaType,
WSDLASTVisitor wsdlVisitor,
VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
holder.setCorbaType(corbaType);
Alias alias = (Alias) corbaType;
//loop through alias base types, till you get a non-alias corba type
CorbaType type = findCorbaType(typeMap, alias.getBasetype());
while ((type != null) && (type instanceof Alias)) {
alias = (Alias) type;
type = findCorbaType(typeMap, alias.getBasetype());
}
QName tname;
if (type == null) {
//it must be a primitive type
tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
} else {
tname = type.getType();
}
XmlSchemaType stype = schemas.getTypeByQName(tname);
if (stype == null) {
XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
if (xmlSchema != null) {
stype = xmlSchema.getTypeByName(tname);
} else {
stype = wsdlVisitor.getSchema().getTypeByName(tname);
}
}
holder.setSchemaType(stype);
}
示例9
public WSDLASTVisitor(String tns, String schemans, String corbatypemaptns, String pragmaPrefix)
throws WSDLException, JAXBException {
manager = new WSDLSchemaManager();
definition = manager.createWSDLDefinition(tns);
inheritScopeMap = new TreeMap<>();
targetNamespace = tns;
schemas = new XmlSchemaCollection();
scopedNames = new ScopeNameCollection();
deferredActions = new DeferredActionCollection();
if (schemans == null) {
schemans = tns;
}
schema = manager.createXmlSchemaForDefinition(definition, schemans, schemas);
declaredWSAImport = false;
typeMap = manager.createCorbaTypeMap(definition, corbatypemaptns);
// idl:sequence<octet> maps to xsd:base64Binary by default
sequenceOctetType = schemas.getTypeByQName(Constants.XSD_BASE64);
// treat bounded corba:string/corba:wstring as unbounded if set to true
setBoundedStringOverride(false);
moduleToNSMapper = new ModuleToNSMapper();
this.setPragmaPrefix(pragmaPrefix);
}
示例10
public PrimitiveTypesVisitor(Scope scopeRef,
Definition defn,
XmlSchema schemaRef,
XmlSchemaCollection xmlSchemas) {
scope = scopeRef;
schemas = xmlSchemas;
}
示例11
public ParamDeferredAction(XmlSchemaElement elem,
Scope ts,
XmlSchema xmlSchema,
XmlSchemaCollection xmlSchemas,
WSDLSchemaManager man,
ModuleToNSMapper map) {
element = elem;
schema = xmlSchema;
schemas = xmlSchemas;
typeScope = ts;
manager = man;
mapper = map;
}
示例12
public FixedPtConstVisitor(Scope scopeRef,
Definition defn,
XmlSchema schemaRef,
XmlSchemaCollection xmlSchemas) {
scope = scopeRef;
schemas = xmlSchemas;
}
示例13
public String generateCodeForSchemaCollection(XmlSchemaCollection collection) {
StringBuilder accumulatedCode = new StringBuilder();
for (XmlSchema schema : collection.getXmlSchemas()) {
if (!Constants.URI_2001_SCHEMA_XSD.equals(schema.getTargetNamespace())) {
accumulatedCode.append(generateCodeForSchema(schema));
}
}
return accumulatedCode.toString();
}
示例14
@Test
public void testSchemas() throws Exception {
setupWSDL(WSDL_PATH);
Types types = newDef.getTypes();
assertNotNull(types);
Collection<ExtensibilityElement> schemas =
CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class);
assertEquals(1, schemas.size());
XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
Element schemaElem = ((Schema)schemas.iterator().next()).getElement();
XmlSchema newSchema = schemaCollection.read(schemaElem);
assertEquals("http://apache.org/hello_world_soap_http/types",
newSchema.getTargetNamespace()
);
}
示例15
public SchemaCollection(XmlSchemaCollection col) {
schemaCollection = col;
if (schemaCollection.getNamespaceContext() == null) {
// an empty prefix map avoids extra checks for null.
schemaCollection.setNamespaceContext(new NamespaceMap());
}
}
示例16
public boolean equals(Object obj) {
if (obj instanceof SchemaCollection) {
return schemaCollection.equals(((SchemaCollection)obj).schemaCollection);
} else if (obj instanceof XmlSchemaCollection) {
return schemaCollection.equals(obj);
}
return false;
}
示例17
@Before
public void setUp() throws Exception {
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
InputStream io = getClass().getClassLoader().getResourceAsStream(schemaPath);
String sysId = getClass().getClassLoader().getResource(schemaPath).toString();
schemaCol.setBaseUri(getTestBaseURI());
schemaCol.read(new StreamSource(io, sysId));
serviceInfo.addSchema(schemaInfo);
schemaInfo.setSchema(schemaCol.getXmlSchema(sysId)[0]);
expect(endpoint.get(anyObject())).andReturn(null);
expect(endpoint.containsKey(anyObject())).andReturn(false);
expect(endpoint.put(anyString(), anyObject())).andReturn(null);
replay(endpoint);
}
示例18
private XmlSchemaInfo loadSchemaInfo(String fileName) throws Exception {
InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
xmlSchemaCollection.read(new InputStreamReader(in), null);
CommonsSchemaInfoBuilder schemaInfoBuilder = new CommonsSchemaInfoBuilder(xmlSchemaCollection);
XmlSchemaInfo schemaInfo = schemaInfoBuilder.createSchemaInfo();
return schemaInfo;
}
示例19
private XmlSchema parseXmlSchema(final InputStream is, final String baseXsdPath) {
try {
XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
schemaCollection.setSchemaResolver(new URIResolver() {
@Override
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
if (resourceLoader != null) {
Resource resource = resourceLoader.getResource(baseXsdPath + "/" + schemaLocation);
if (resource.exists()) {
try {
return new InputSource(resource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Exception occurred", e);
}
}
}
return new InputSource(Thread.currentThread().getContextClassLoader()
.getResourceAsStream(baseXsdPath + "/" + schemaLocation));
}
});
return schemaCollection.read(new InputSource(is), null);
} catch (Exception exception) {
throw new RuntimeException(exception);
} finally {
try {
is.close();
} catch (IOException ioException) {
LOG.error("ioExecption in closing input file ", ioException);
}
}
}
示例20
@SuppressWarnings("PMD.DoNotThrowExceptionInFinally") // seems necessary to report issue while closing input stream
private XmlSchema parseXmlSchema(final InputStream is) {
try {
XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
schemaCollection.setSchemaResolver(new URIResolver() {
@Override
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
if (resourceLoader != null) {
Resource resource = resourceLoader.getResource(getXsdPath() + "/" + schemaLocation);
if (resource.exists()) {
try {
return new InputSource(resource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Exception occurred", e);
}
}
}
return new InputSource(Thread.currentThread().getContextClassLoader()
.getResourceAsStream(getXsdPath() + "/" + schemaLocation));
}
});
return schemaCollection.read(new InputSource(is), null);
} catch (Exception exception) {
throw new RuntimeException(exception);
} finally {
try {
is.close();
} catch (IOException ioException) {
throw new RuntimeException(ioException);
}
}
}
示例21
@SuppressWarnings("PMD.DoNotThrowExceptionInFinally") // smooks support soon to be removed
private XmlSchema parseXmlSchema(final InputStream is, final String baseXsdPath) {
try {
XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
// schemaCollection.setBaseUri(baseUri);
schemaCollection.setSchemaResolver(new URIResolver() {
@Override
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
if (resourceLoader != null) {
Resource resource = resourceLoader.getResource(baseXsdPath + "/" + schemaLocation);
if (resource.exists()) {
try {
return new InputSource(resource.getInputStream());
} catch (IOException e) {
throw new RuntimeException("Exception occurred", e);
}
}
}
return new InputSource(Thread.currentThread().getContextClassLoader()
.getResourceAsStream(baseXsdPath + "/" + schemaLocation));
}
});
return schemaCollection.read(new InputSource(is), null);
} catch (Exception exception) {
throw new RuntimeException(exception);
} finally {
try {
is.close();
} catch (IOException ioException) {
throw new RuntimeException(ioException);
}
}
}
示例22
public static void main(String[] args) throws IOException, JAXBException {
OptionParser parser = new OptionParser();
OptionSpec<File> schemaOpt = parser.accepts("schema").withRequiredArg().ofType(File.class).required();
OptionSpec<String> modelOpt = parser.accepts("model").withRequiredArg().ofType(String.class);
OptionSpec<File> configOpt = parser.accepts("config").withOptionalArg().ofType(File.class);
OptionSpec<File> outputOpt = parser.accepts("output").withRequiredArg().ofType(File.class);
OptionSpec<String> normalizePrefixOpt = parser.accepts("normalize-prefix").withRequiredArg().ofType(String.class);
OptionSpec<ModelImporterOptions.ChoiceTypePolicy> choiceTypeOpt =
parser.accepts("choicetype-policy").withRequiredArg().ofType(ModelImporterOptions.ChoiceTypePolicy.class);
OptionSpec<ModelImporterOptions.SimpleTypeRestrictionPolicy> stRestrictionsOpt =
parser.accepts("simpletype-restriction-policy").withRequiredArg().ofType(ModelImporterOptions.SimpleTypeRestrictionPolicy.class);
OptionSpec<ModelImporterOptions.ElementRedeclarationPolicy> redeclarationsOpt =
parser.accepts("element-redeclaration-policy").withRequiredArg().ofType(ModelImporterOptions.ElementRedeclarationPolicy.class);
OptionSpec<ModelImporterOptions.VersionPolicy> versionPolicyOpt =
parser.accepts("version-policy").withRequiredArg().ofType(ModelImporterOptions.VersionPolicy.class);
OptionSpec<File> optionsFileOpt = parser.accepts("options-file").withRequiredArg().ofType(File.class);
OptionSet options = parser.parse(args);
File schemaFile = schemaOpt.value(options);
InputStream is = new FileInputStream(schemaFile);
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
schemaCol.setBaseUri(schemaFile.getParent());
XmlSchema schema = schemaCol.read(new StreamSource(is));
ModelImporterOptions importerOptions;
if (options.has(optionsFileOpt)) {
importerOptions = ModelImporterOptions.loadFromProperties(optionsFileOpt.value(options));
}
else {
importerOptions = new ModelImporterOptions();
}
if (options.has(modelOpt)) {
importerOptions.setModel(modelOpt.value(options));
}
if (options.has(choiceTypeOpt)) {
importerOptions.setChoiceTypePolicy(choiceTypeOpt.value(options));
}
if (options.has(stRestrictionsOpt)) {
importerOptions.setSimpleTypeRestrictionPolicy(stRestrictionsOpt.value(options));
}
if (options.has(redeclarationsOpt)) {
importerOptions.setElementRedeclarationPolicy(redeclarationsOpt.value(options));
}
if (options.has(versionPolicyOpt)) {
importerOptions.setVersionPolicy(versionPolicyOpt.value(options));
}
if (options.has(normalizePrefixOpt)) {
importerOptions.setNormalizePrefix(normalizePrefixOpt.value(options));
}
ModelInfo config = null;
if (configOpt != null) {
File configFile = configOpt.value(options);
if (configFile != null) {
config = JAXB.unmarshal(configFile, ModelInfo.class);
}
}
ModelInfo modelInfo = ModelImporter.fromXsd(schema, importerOptions, config);
JAXBContext jc = JAXBContext.newInstance(ModelInfo.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
File outputfile;
if (! options.has(outputOpt) || outputOpt.value(options).isDirectory()) {
// construct output filename using modelinfo
String name = String.format("%s-modelinfo.xml", modelInfo.getTargetQualifier().getLocalPart());
String basePath = options.has(outputOpt) ? outputOpt.value(options).getAbsolutePath() : schemaFile.getParent();
outputfile = new File(basePath + File.separator + name);
} else {
outputfile = outputOpt.value(options);
}
if (outputfile.equals(schemaFile)) {
throw new IllegalArgumentException("input schema file and output file must be different!");
}
OutputStream os = new FileOutputStream(outputfile, false);
try {
OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");
marshaller.marshal(new ObjectFactory().createModelInfo(modelInfo), writer);
}
finally {
os.close();
}
}
示例23
public XmlSchema createXmlSchema(String schemans, XmlSchemaCollection schemaCol) {
XmlSchema xmlSchema = new XmlSchema(schemans, schemaCol);
schemas.put(schemans, xmlSchema);
return xmlSchema;
}
示例24
public XmlSchema createXmlSchemaForDefinition(Definition defn, String schemans,
XmlSchemaCollection schemaCol) {
XmlSchema xmlSchema = createXmlSchema(schemans, schemaCol);
defnSchemas.put(schemans, xmlSchema);
return xmlSchema;
}
示例25
private static boolean findSchemaTypeInGlobalScope(Scope scope,
Definition defn,
XmlSchema currentSchema,
AST node,
WSDLASTVisitor wsdlVisitor,
VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
ModuleToNSMapper mapper = wsdlVisitor.getModuleToNSMapper();
WSDLSchemaManager manager = wsdlVisitor.getManager();
Scope scopedName = new Scope(scope, node);
String name = node.toString();
if (isFullyScopedName(node)) {
scopedName = getFullyScopedName(new Scope(), node);
name = scopedName.toString();
}
boolean result = findNonSchemaType(name, wsdlVisitor, holder);
if (!result) {
XmlSchema xmlSchema = currentSchema;
QName qname = null;
String tns = mapper.map(scopedName.getParent());
if (tns != null) {
xmlSchema = manager.getXmlSchema(tns);
if (xmlSchema != null) {
qname = new QName(xmlSchema.getTargetNamespace(), scopedName.tail());
}
} else {
qname = new QName(xmlSchema.getTargetNamespace(), name);
}
XmlSchemaType stype = null;
if (qname != null) {
// Exceptions are treated as a special case as above
if (exceptionMode) {
qname = new QName(xmlSchema.getTargetNamespace(), qname.getLocalPart() + "Type");
}
stype = xmlSchema.getTypeByName(qname);
if (stype == null) {
stype = schemas.getTypeByQName(qname);
}
}
if (stype != null) {
result = true;
if (holder != null) {
holder.setSchemaType(stype);
holder.setCorbaType(getCorbaSchemaType(xmlSchema, typeMap, stype, scopedName));
//add a xmlschema import
if (!currentSchema.getTargetNamespace().equals(xmlSchema.getTargetNamespace())) {
String importFile = wsdlVisitor.getOutputDir()
+ System.getProperty("file.separator")
+ scopedName.getParent().toString("_");
manager.addXmlSchemaImport(currentSchema, xmlSchema, importFile);
}
}
}
}
return result;
}
示例26
private static boolean findScopeSchemaType(Scope scopedName, XmlSchema schemaRef,
WSDLASTVisitor wsdlVisitor,
VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
ModuleToNSMapper mapper = wsdlVisitor.getModuleToNSMapper();
WSDLSchemaManager manager = wsdlVisitor.getManager();
boolean result = findNonSchemaType(scopedName.toString(), wsdlVisitor, holder);
if (!result) {
QName qname = null;
XmlSchema xmlSchema = schemaRef;
String tns = wsdlVisitor.getModuleToNSMapper().map(scopedName.getParent());
if (tns != null) {
xmlSchema = wsdlVisitor.getManager().getXmlSchema(tns);
}
XmlSchemaType stype = null;
if (xmlSchema != null) {
// Exceptions are treated as a special case as for the
// doc/literal style
// in the schema we will have an element and a complextype
// so the name
// and the typename will be different.
String scopedNameString = null;
if (mapper.isDefaultMapping()) {
scopedNameString = scopedName.toString();
} else {
scopedNameString = scopedName.tail();
}
if (exceptionMode) {
qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString + "Type");
} else {
qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString);
}
stype = xmlSchema.getTypeByName(qname);
if (stype == null) {
stype = schemas.getTypeByQName(qname);
}
}
if (stype != null) {
result = true;
}
if (result && holder != null) {
holder.setSchemaType(stype);
holder.setCorbaType(getCorbaSchemaType(xmlSchema, typeMap, stype, scopedName));
// add a xmlschema import
if (!schemaRef.getTargetNamespace().equals(xmlSchema.getTargetNamespace())) {
String importFile = wsdlVisitor.getOutputDir() + System.getProperty("file.separator")
+ scopedName.getParent().toString("_");
manager.addXmlSchemaImport(schemaRef, xmlSchema, importFile);
}
}
}
return result;
}
示例27
public XmlSchemaCollection getSchemas() {
return schemas;
}
示例28
public SequenceDeferredAction(XmlSchemaCollection xmlSchemas,
XmlSchema xmlSchema) {
schemas = xmlSchemas;
schema = xmlSchema;
}
示例29
public void process() throws ToolException {
super.process();
ServiceInfo serviceInfo = context.get(ServiceInfo.class);
File jsFile = getOutputFile(serviceInfo.getName().getLocalPart() + ".js");
BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo, null);
NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
.getXmlSchemaCollection());
Map<String, String> nsPrefixMap =
CastUtils.cast(
context.get(ToolConstants.CFG_JSPREFIXMAP, Map.class),
String.class, String.class);
if (nsPrefixMap != null) {
for (Map.Entry<String, String> prefixEntry : nsPrefixMap.entrySet()) {
prefixManager.collect(prefixEntry.getValue(), prefixEntry.getKey());
}
}
try {
OutputStream outputStream = Files.newOutputStream(jsFile.toPath());
if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) {
JavascriptGetInterceptor.writeUtilsToResponseStream(WSDLToJavaScriptProcessor.class,
outputStream);
}
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, UTF_8);
try (BufferedWriter writer = new BufferedWriter(outputStreamWriter)) {
XmlSchemaCollection collection = serviceInfo.getXmlSchemaCollection().getXmlSchemaCollection();
SchemaJavascriptBuilder jsBuilder =
new SchemaJavascriptBuilder(serviceInfo
.getXmlSchemaCollection(), prefixManager, nameManager);
String jsForSchemas = jsBuilder.generateCodeForSchemaCollection(collection);
writer.append(jsForSchemas);
ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
null,
prefixManager,
nameManager);
serviceBuilder.walk();
String serviceJavascript = serviceBuilder.getCode();
writer.append(serviceJavascript);
}
} catch (IOException e) {
throw new ToolException(e);
}
}
示例30
public XmlSchema addTypesSchemaDocument(XmlSchemaCollection collection) {
return collection.read(getAegisTypesSchemaDocument(), null);
}