/** * This copes with an observed phenomenon in the schema built by the * ReflectionServiceFactoryBean. It is creating element such that: (a) the * type is not set. (b) the refName is set. (c) the namespaceURI in the * refName is set empty. This apparently indicates 'same Schema' to everyone * else, so thus function implements that convention here. It is unclear if * that is a correct structure, and it if changes, we can simplify or * eliminate this function. * * @param name * @param referencingURI */ public static XmlSchemaElement findElementByRefName(SchemaCollection xmlSchemaCollection, QName name, String referencingURI) { String uri = name.getNamespaceURI(); if ("".equals(uri)) { uri = referencingURI; } QName copyName = new QName(uri, name.getLocalPart()); XmlSchemaElement target = xmlSchemaCollection.getElementByQName(copyName); assert target != null; return target; }
private static void factorySetupType(XmlSchemaElement element, SchemaCollection schemaCollection, ParticleInfo elementInfo) { elementInfo.type = element.getSchemaType(); if (elementInfo.type == null) { if (element.getSchemaTypeName() == null // no type at all -> anyType || element.getSchemaTypeName().equals(Constants.XSD_ANYTYPE)) { elementInfo.anyType = true; } else { elementInfo.type = schemaCollection.getTypeByQName(element.getSchemaTypeName()); if (elementInfo.type == null && !element.getSchemaTypeName() .getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) { JavascriptUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName() .toString(), element.getQName(), element); } } } else if (elementInfo.type.getQName() != null && Constants.XSD_ANYTYPE.equals(elementInfo.type.getQName())) { elementInfo.anyType = true; } }
public XmlSchemaType getSchemaType(QName name) throws Exception { XmlSchemaType type = null; for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) { String nspace = name.getNamespaceURI(); if (nspace == null) { nspace = xmlSchema.getTargetNamespace(); } //QName tname = createQName(nspace, name.getLocalPart(), "xsd"); QName tname = createQName(nspace, name.getLocalPart(), ""); type = findSchemaType(tname); if (type != null) { break; } } return type; }
public static XmlSchemaType getXmlSchemaType(ServiceInfo serviceInfo, QName name) { XmlSchemaType result = null; if ((name != null) && (serviceInfo != null)) { SchemaCollection col = serviceInfo.getXmlSchemaCollection(); result = col.getTypeByQName(name); if (result == null) { //check the name, if it is an element XmlSchemaElement el = col.getElementByQName(name); if (el != null) { result = el.getSchemaType(); } } } return result; }
protected void initializeMessageTypes(ServiceInfo s, AbstractMessageContainer container, int partType) { if (container == null) { return; } SchemaCollection col = s.getXmlSchemaCollection(); for (MessagePartInfo part : container.getMessageParts()) { if (part.getXmlSchema() == null) { if (part.isElement()) { XmlSchemaAnnotated tp = col.getElementByQName(part.getElementQName()); part.setXmlSchema(tp); } else { XmlSchemaAnnotated tp = col.getTypeByQName(part.getTypeQName()); part.setXmlSchema(tp); } } } }
public ISchemaResolver resolve(String loc, String tns) throws IOException { URIResolver resolver = collection.getXmlSchemaCollection().getSchemaResolver(); InputSource source = resolver.resolveEntity(tns, loc, id); SchemaCollection schemaCol = new SchemaCollection(); schemaCol.setSchemaResolver(resolver); XmlSchema read = schemaCol.getXmlSchemaCollection().read(source); String uri = loc; try { URL url = new URL(new URL(id), loc); uri = url.toURI().toString(); } catch (Exception e) { // do nothing } return new JibxSchemaResolver(uri, read, schemaCol, null); } }
+ msg.getQName().getLocalPart() + " does not specify a name."); QName pqname = new QName(minfo.getName().getNamespaceURI(), part.getName()); MessagePartInfo pi = minfo.getMessagePart(pqname); if (pi != null && pi.getMessageInfo().getName().equals(msg.getQName())) { continue; if (!minfo.getName().equals(msg.getQName())) { pi.setMessageContainer(new MessageInfo(minfo.getOperation(), null, msg.getQName())); pi.setTypeQName(part.getTypeName()); pi.setElement(false); pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName())); } else { pi.setElementQName(part.getElementName()); pi.setElement(true); pi.setXmlSchema(schemas.getElementByQName(part.getElementName())); pi.setProperty(OUT_OF_BAND_HEADER, Boolean.TRUE);
return null; SchemaCollection xmlSchemaCollection = new SchemaCollection(); Collection<DOMSource> schemas = new HashSet<>(); List<String> targetNamespaces = new ArrayList<>(); QName typeName = theResolver.resolve(cls, new Annotation[] {}, Collections.<Class<?>, QName> emptyMap()); if (typeName != null && tns.equals(typeName.getNamespaceURI())) { QName elementName = resourceTypes.getXmlNameMap().get(cls); if (elementName == null) { newElement.setAttribute("name", elementName.getLocalPart()); newElement.setAttribute("type", tnsPrefix + typeName.getLocalPart());
protected QName checkPrefix(QName schematypeName) { QName name = schematypeName; if ((name != null) && (name.getPrefix() == null || name.getPrefix().isEmpty())) { if (StringUtils.isEmpty(name.getNamespaceURI())) { return name; } String prefix = def.getPrefix(name.getNamespaceURI()); if (prefix == null) { prefix = xmlSchemaList.getSchemaByTargetNamespace(name.getNamespaceURI()) .getNamespaceContext().getPrefix(name.getNamespaceURI()); } if (prefix != null) { return new QName(name.getNamespaceURI(), name.getLocalPart(), prefix); } return null; } return name; }
private void buildMessage(AbstractMessageContainer minfo, Message msg) { SchemaCollection schemas = minfo.getOperation().getInterface().getService() .getXmlSchemaCollection(); List<?> orderedParam = msg.getOrderedParts(null); for (Part part : cast(orderedParam, Part.class)) { MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(), part .getName())); if (part.getTypeName() != null) { pi.setTypeQName(part.getTypeName()); pi.setElement(false); pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName())); } else if (part.getElementName() != null) { pi.setElementQName(part.getElementName()); XmlSchemaElement schemaElement = schemas.getElementByQName(part.getElementName()); if (null == schemaElement) { org.apache.cxf.common.i18n.Message errorMessage =
protected void buildService(ServiceInfo serviceInfo, Definition definition) { Map<QName, MessageInfo> messages = serviceInfo.getMessages(); for (Map.Entry<QName, MessageInfo> mie : messages.entrySet()) { if (!mie.getKey().getNamespaceURI().equals(definition.getTargetNamespace())) { continue; for (MessagePartInfo mpi : mie.getValue().getMessageParts()) { Part part = definition.createPart(); boolean elemental = mpi.isElement(); && null == serviceInfo.getXmlSchemaCollection(). getElementByQName(mpi.getElementQName())) { elemental = false; part.setElementName(mpi.getElementQName()); } else { part.setTypeName(mpi.getTypeQName()); part.setName(mpi.getName().getLocalPart()); message.addPart(part); addDocumentation(definition, serviceInfo.getTopLevelDoc()); Service serv = definition.createService(); addDocumentation(serv, serviceInfo.getDocumentation()); serv.setQName(serviceInfo.getName()); addNamespace(serviceInfo.getName().getNamespaceURI(), definition); addExtensibilityElements(definition, serv, getWSDL11Extensors(serviceInfo)); definition.addService(serv);
protected void addElement(XmlSchema schema, XmlSchemaSequence seq, JAXBBeanInfo beanInfo, QName name, boolean isArray, XmlElement xmlElementAnno) { XmlSchemaElement el = new XmlSchemaElement(schema, false); if (isArray) { el.setMinOccurs(0); el.setMaxOccurs(Long.MAX_VALUE); } else { if (xmlElementAnno == null) { QName ename = new QName(beanInfo.getElementNamespaceURI(null), beanInfo.getElementLocalName(null)); XmlSchemaElement el2 = schemas.getElementByQName(ename); el.setNillable(false); el.getRef().setTargetQName(el2.getQName()); el.setName(xmlElementAnno.name()); } else { el.setName(name.getLocalPart());
String ns = t.getSchemaType().getNamespaceURI(); Set<AegisType> types = tns2Type.get(ns); if (types == null) { SchemaCollection col = si.getXmlSchemaCollection(); if (col.getXmlSchemas().length > 1) { SchemaInfo schemaInfo = si.addNewSchema(entry.getKey()); XmlSchema schema = schemaInfo.getSchema(); NamespaceMap xmlsNamespaceMap = new NamespaceMap(); schema.setNamespaceContext(xmlsNamespaceMap); schema.setTargetNamespace(entry.getKey()); schema.setElementFormDefault(XmlSchemaForm.QUALIFIED); schema.setAttributeFormDefault(XmlSchemaForm.QUALIFIED); XmlSchema schema = aegisContext.addXmimeSchemaDocument(si.getXmlSchemaCollection() .getXmlSchemaCollection()); SchemaInfo schemaInfo = new SchemaInfo(schema.getTargetNamespace()); schemaInfo.setSchema(schema); si.addSchema(schemaInfo); XmlSchema schema = aegisContext.addTypesSchemaDocument(si.getXmlSchemaCollection() .getXmlSchemaCollection()); SchemaInfo schemaInfo = new SchemaInfo(schema.getTargetNamespace()); schemaInfo.setSchema(schema); si.getXmlSchemaCollection().addCrossImports();
XmlSchemaType containingType) { assert element != null; if (element.getSchemaTypeName() != null) { XmlSchemaType type = xmlSchemaCollection.getTypeByQName(element.getSchemaTypeName()); if (type == null) { Message message = new Message("ELEMENT_TYPE_MISSING", LOG, element.getQName(), element.getSchemaTypeName().toString()); throw new UnsupportedConstruct(message); if (xmlSchemaCollection.getSchemaByTargetNamespace(referencingURI) == null) { referencingURI = null; referencingURI = containingType.getQName().getNamespaceURI();
XmlSchemaElement element = (XmlSchemaElement)particle; QName elementQName = XmlSchemaUtils.getElementQualifiedName(element, currentSchema); String elementNamespaceURI = elementQName.getNamespaceURI(); elementSchema = schemaCollection.getSchemaByTargetNamespace(elementNamespaceURI); if (elementSchema == null) { throw new RuntimeException("Missing schema " + elementNamespaceURI); elementInfo.javascriptName = elementQName.getLocalPart(); String schemaDefaultValue = element.getDefaultValue();
String attributeNamespaceURI = attribute.getQName().getNamespaceURI(); boolean attributeNoNamespace = "".equals(attributeNamespaceURI); attributeSchema = schemaCollection.getSchemaByTargetNamespace(attributeNamespaceURI); if (attributeSchema == null) { throw new RuntimeException("Missing schema " + attributeNamespaceURI); attributeInfo.javascriptName = attribute.getQName().getLocalPart(); attributeInfo.defaultValue = attribute.getDefaultValue(); attributeInfo.fixedValue = attribute.getFixedValue();
private static void factorySetupType(XmlSchemaAttribute element, SchemaCollection schemaCollection, AttributeInfo attributeInfo) { attributeInfo.type = element.getSchemaType(); if (attributeInfo.type == null) { if (element.getSchemaTypeName().equals(Constants.XSD_ANYTYPE)) { attributeInfo.anyType = true; } else { attributeInfo.type = schemaCollection.getTypeByQName(element.getSchemaTypeName()); if (attributeInfo.type == null && !element.getSchemaTypeName() .getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) { JavascriptUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName() .toString(), element.getQName(), element); } } } else if (attributeInfo.type.getQName() != null && Constants.XSD_ANYTYPE.equals(attributeInfo.type.getQName())) { attributeInfo.anyType = true; } }
private void createBridgeXsElement(MessagePartInfo part, QName qn, QName typeName) { XmlSchemaElement el = null; SchemaInfo schemaInfo = serviceInfo.getSchema(qn.getNamespaceURI()); if (schemaInfo != null) { el = schemaInfo.getElementByQName(qn); if (el == null) { createXsElement(schemaInfo.getSchema(), part, typeName, schemaInfo); } else if (!typeName.equals(el.getSchemaTypeName())) { throw new Fault(new Message("CANNOT_CREATE_ELEMENT", LOG, qn, typeName, el.getSchemaTypeName())); } return; } XmlSchema schema = schemas.newXmlSchemaInCollection(qn.getNamespaceURI()); if (qualifiedSchemas) { schema.setElementFormDefault(XmlSchemaForm.QUALIFIED); } schemaInfo = new SchemaInfo(qn.getNamespaceURI(), qualifiedSchemas, false); schemaInfo.setSchema(schema); el = createXsElement(schema, part, typeName, schemaInfo); NamespaceMap nsMap = new NamespaceMap(); nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace()); nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD); schema.setNamespaceContext(nsMap); serviceInfo.addSchema(schemaInfo); }
XmlSchemaElement element = null; XmlSchemaType type = null; QName diagnosticName = mpi.getName(); if (mpi.isElement()) { element = (XmlSchemaElement)mpi.getXmlSchema(); if (element == null) { element = XmlSchemaUtils.findElementByRefName(xmlSchemaCollection, mpi.getElementQName(), serviceInfo.getTargetNamespace()); diagnosticName = element.getQName(); type = element.getSchemaType(); if (type == null) { type = getElementType(xmlSchemaCollection, type = (XmlSchemaType)mpi.getXmlSchema(); if (type == null) { type = xmlSchemaCollection.getTypeByQName(mpi.getTypeQName()); diagnosticName = type.getQName(); JavascriptUtils.javaScriptNameToken(mpi.getConcreteName().getLocalPart()); String elementXmlRef = prefixAccumulator.xmlElementString(mpi.getConcreteName()); ParticleInfo elementInfo = ParticleInfo.forPartElement(element,
File jsFile = getOutputFile(serviceInfo.getName().getLocalPart() + ".js"); .getXmlSchemaCollection()); writer = new BufferedWriter(outputStreamWriter); XmlSchemaCollection collection = serviceInfo.getXmlSchemaCollection().getXmlSchemaCollection(); SchemaJavascriptBuilder jsBuilder = new SchemaJavascriptBuilder(serviceInfo