private static Element removeSchemaImports(Element schema) { // // remove <xsd:import> elements // Element[] imports = XmlUtils.getElements(schema, XsdUtils.IMPORT_QNAME); for (int i = 0; i < imports.length; ++i) imports[i].removeAttribute(XsdUtils.SCHEMA_LOCATION); return schema; }
private static Element removeSchemaIncludes(Element schema) { // // remove <xsd:include> elements // Element[] includes = XmlUtils.getElements(schema, XsdUtils.INCLUDE_QNAME); for (int i = 0; i < includes.length; ++i) schema.removeChild(includes[i]); return schema; }
/** * * Iterates over a WSDL document and removes all WSDL imports and XSD * imports. This is useful if you are trying to load a remote WSDL into an * API such as WSDL4J, which tries to resolve imports. WSDL4J allows you to * shut off WSDL imports, but not XSD imports, so removing these before * parsing is important. * * @param wsdl * The WSDL Document whose import elements will be removed. * * @return The given WSDL Document. * */ public static Element removeWsdlReferences(Element wsdl) { // // first remove the <wsdl:import> elements // Element[] imports = XmlUtils.getElements(wsdl, WsdlUtils.IMPORT_QNAME); for (int i = 0; i < imports.length; ++i) wsdl.removeChild(imports[i]); return wsdl; } }
protected Map createInitializationParameters(Element xml) { Map parameters = new HashMap(); Element[] paramXML = XmlUtils.getElements(xml, DescriptorConstants.INIT_PARAM_QNAME); for (int n = 0; n < paramXML.length; ++n) { String name = XmlUtils.getElementText(paramXML[n], DescriptorConstants.PARAM_NAME_QNAME); String value = XmlUtils.getElementText(paramXML[n], DescriptorConstants.PARAM_VALUE_QNAME); parameters.put(name, value); } return parameters; }
/** * * @param rmd * An XML document containing a root element named wsrmd:Definitions. * * @param name * The value of the <em>name</em> attribute for the desired * metadata descriptor. * * @return The metadata descriptor in the document that has the given name, * or null if the name is not found. * */ public static Element getMetadataDescriptor(Document rmd, String name) { Element root = XmlUtils.getFirstElement(rmd); // wsrmd:Definitions Element[] descriptors = XmlUtils.getElements(root, WsrmdConstants.DESCRIPTOR_QNAME); for (int n = 0; n < descriptors.length; ++n) { String nextAttr = descriptors[n].getAttribute(WsrmdConstants.NAME); if (nextAttr != null && nextAttr.equals(name)) return descriptors[n]; } return null; } }
public Collection createSerializerDefinitions(Element xml, Environment env) throws SoapFault { QName qname = DescriptorConstants.CUSTOM_SERIALIZER_QNAME; Element[] serializerXML = XmlUtils.getElements(xml, qname); Collection definitions = new ArrayList(serializerXML.length); for (int n = 0; n < serializerXML.length; ++n) { SerializerDescriptor sd = createSerializerDescriptor(); sd.load(serializerXML[n], env); SerializerDefinition definition = sd.getSerializerDefinition(); definitions.add(definition); } return definitions; }
/** * * Gathers the target namespaces for each schema in the WSDL's * <em>types</em> section. * * @param wsdl * * @return The set of schema namespaces declared in the <em>types</em> * section. * */ public static Set getSchemaNamespaces(Document wsdl) { Element root = XmlUtils.getFirstElement(wsdl); Element types = XmlUtils.getElement(root, TYPES_QNAME); Element[] schemas = XmlUtils.getElements(types, XsdUtils.SCHEMA_QNAME); Set namespaces = new HashSet(); // // each schema should have a targetNamespace attribute // for (int n = 0; n < schemas.length; ++n) namespaces.add(schemas[n].getAttribute(XmlUtils.TARGET_NS)); return namespaces; }
protected Collection createResourceDefinitions(Element xml, Environment env) throws SoapFault { Element[] resourceXML = XmlUtils.getElements(xml, DescriptorConstants.RESOURCE_TYPE_QNAME); Collection definitions = new ArrayList(resourceXML.length); for (int n = 0; n < resourceXML.length; ++n) { ResourceDescriptor rd = createResourceDescriptor(); rd.load(resourceXML[n], env); ResourceDefinition definition = rd.getResourceDefinition(); definitions.add(definition); } return definitions; }
public Collection createSerializerDefinitions(Element xml, Environment env) throws SoapFault { QName qname = DescriptorConstants.CUSTOM_SERIALIZER_QNAME; Element[] serializerXML = XmlUtils.getElements(xml, qname); Collection definitions = new ArrayList(serializerXML.length); for (int n = 0; n < serializerXML.length; ++n) { SerializerDescriptor sd = createSerializerDescriptor(); sd.load(serializerXML[n], env); SerializerDefinition definition = sd.getSerializerDefinition(); definitions.add(definition); } return definitions; }
root = XmlUtils.getFirstElement(wsdl); Element[] portTypes = XmlUtils.getElements(root, PORT_TYPE_QNAME);
/** * Loads the context paths from the muse.xml descriptor * @param xml * @param env * @return the context paths contianed by the descriptor * @throws SoapFault * * @see DeploymentDescriptor#loadContextPaths(Document, Environment) */ public Collection loadContextPaths(Document xml, Environment env) throws SoapFault { if (xml == null) throw new NullPointerException(_MESSAGES.get("NullDescriptorDocument")); Element root = XmlUtils.getElement(xml, DescriptorConstants.MUSE_QNAME); Element[] resourceXML = XmlUtils.getElements(root, DescriptorConstants.RESOURCE_TYPE_QNAME); ArrayList contextPaths = new ArrayList(resourceXML.length); QName qname = DescriptorConstants.CONTEXT_PATH_QNAME; for (int n = 0; n < resourceXML.length; ++n) { String path = XmlUtils.getElementText(resourceXML[n], qname); if (path == null) continue; contextPaths.add(path); } return contextPaths; }
public static Element removeSchemaReferences(Element wsdl) { Element types = XmlUtils.getElement(wsdl, WsdlUtils.TYPES_QNAME); Element[] schemas = XmlUtils.getElements(types, XsdUtils.SCHEMA_QNAME); for (int i = 0; i < schemas.length; ++i) { removeSchemaImports(schemas[i]); removeSchemaIncludes(schemas[i]); } return wsdl; }
public SimpleTopicNamespace(Element root) throws BaseFault { if (root == null) throw new NullPointerException(_MESSAGES.get("NullTopicSpaceElement")); _targetNamespace = root.getAttribute(XmlUtils.TARGET_NS); if (_targetNamespace == null) throw new InvalidTopicExpressionFault(_MESSAGES.get("NoTopicSpaceNS")); _name = root.getAttribute(XsdUtils.NAME); Element[] children = XmlUtils.getElements(root, WstConstants.TOPIC_QNAME); for (int n = 0; n < children.length; ++n) { Topic topic = new SimpleTopic(children[n], this); addTopic(topic); } }
/** * creates the set of resource definitions for a deployment descriptor. * @param xml * @param env * @return a collection of <code>OSGiResourceDescriptor</code> objects * @throws SoapFault * * @see OSGiResourceDescriptor */ protected Collection createResourceDefinitions(Element xml, Environment env) throws SoapFault { Element[] resourceXML = XmlUtils.getElements(xml, DescriptorConstants.RESOURCE_TYPE_QNAME); Collection definitions = new ArrayList(resourceXML.length); for (int n = 0; n < resourceXML.length; ++n) { OSGiResourceDescriptor rd = (OSGiResourceDescriptor) createResourceDescriptor(); rd.setBundle(bundle); rd.load(resourceXML[n], env); ResourceDefinition definition = rd.getResourceDefinition(); definitions.add(definition); } return definitions; }
/** * * This is a convenience method that resolves all of the schema imports * referenced in a WSDL. It iterates over every schema in the WSDL's * <em>types</em> section and processes it via XsdUtils.addImports(). * * @return The given WSDL, now with the imported schemas added to its * <em>types</em> section. * */ public static Document addSchemaImports(Document wsdl, String wsdlPath, Environment environment, Set namespaces) { Element root = XmlUtils.getFirstElement(wsdl); Element types = XmlUtils.getElement(root, TYPES_QNAME); Element[] schemas = XmlUtils.getElements(types, XsdUtils.SCHEMA_QNAME); for (int n = 0; n < schemas.length; ++n) addSchemaImports(types, schemas[n], wsdlPath, environment, namespaces); return wsdl; }
/** * * This is a convenience method that resolves all of the schema includes * referenced in a WSDL. It iterates over every schema in the WSDL's * <em>types</em> section and processes it via XsdUtils.addIncludes(). * * @return The given WSDL, now with the included schemas added to its * <em>types</em> section. * */ public static Document addSchemaIncludes(Document wsdl, String wsdlPath, Environment environment, Set namespaces) { Element root = XmlUtils.getFirstElement(wsdl); Element types = XmlUtils.getElement(root, TYPES_QNAME); Element[] schemas = XmlUtils.getElements(types, XsdUtils.SCHEMA_QNAME); for (int n = 0; n < schemas.length; ++n) addSchemaIncludes(schemas[n], schemas[n], wsdlPath, environment, namespaces); return wsdl; }
public String getWsdlPathForContext(Document xml, String context) throws SoapFault { if (xml == null) throw new NullPointerException(_MESSAGES.get("NullDescriptorDocument")); if (context == null) return null; Element root = XmlUtils.getElement(xml, DescriptorConstants.MUSE_QNAME); Element[] resourceXML = XmlUtils.getElements(root, DescriptorConstants.RESOURCE_TYPE_QNAME); if(resourceXML == null) return null; QName qname = DescriptorConstants.CONTEXT_PATH_QNAME; for(int i=0;i<resourceXML.length;i++){ String path = XmlUtils.getElementText(resourceXML[i], qname); if(context.equals(path)){ Element wsdlElement = XmlUtils.getElement(resourceXML[i], DescriptorConstants.WSDL_QNAME); if(wsdlElement != null) return XmlUtils.getElementText(wsdlElement,DescriptorConstants.WSDL_FILE_QNAME); break; } } return null; }
return XmlUtils.getElements(sequence, XsdUtils.ELEMENT_QNAME); Element[] childProperties = XmlUtils.getElements(sequence, XsdUtils.ELEMENT_QNAME);
public GetMultipleRequest(Element request) throws InvalidMessageFormatFault { if (request == null) throw new NullPointerException(_MESSAGES.get("NullRequestElement")); // // load the property QNames from the ResourceProperty elements... // QName qname = WsrpConstants.PROPERTY_QNAME; Element[] properties = XmlUtils.getElements(request, qname); if (properties.length == 0) throw new InvalidMessageFormatFault(_MESSAGES.get("NoPropertiesInGet")); _qnames = new QName[properties.length]; for (int n = 0; n < properties.length; ++n) { _qnames[n] = XmlUtils.getQName(properties[n]); if (_qnames[n] == null) { Object[] filler = { new Integer(n) }; throw new InvalidMessageFormatFault(_MESSAGES.get("NullPropertyN", filler)); } } }
public InsertRequest(Element request) throws BaseFault { if (request == null) throw new NullPointerException(_MESSAGES.get("NullRequestElement")); Element[] children = XmlUtils.getAllElements(request); if (children.length == 0) throw new InvalidMessageFormatFault(_MESSAGES.get("NoPropertiesFoundInsert")); // // the WS-RP spec says that in an Insert request with multiple // elements, all elements MUST have the same qualified name // QName firstQName = XmlUtils.getElementQName(children[0]); Element[] matches = XmlUtils.getElements(request, firstQName); if (matches.length != children.length) throw new InvalidMessageFormatFault(_MESSAGES.get("NamesNotEqualInsert")); setPropertyName(firstQName); setValues(children); }