List of usage examples for org.w3c.dom Node getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderCatalogXmlTests.java
public static Collection<Object[]> getReferencedCatalogUrlsUsingXML(String base) throws IOException, ParserConfigurationException, SAXException, XPathException { staticSetup();/*w w w. java 2 s . co m*/ HttpResponse resp = OSLCUtils.getResponseFromUrl(base, base, basicCreds, OSLCConstants.CT_XML, headers); int statusCode = resp.getStatusLine().getStatusCode(); if (HttpStatus.SC_OK != statusCode) { EntityUtils.consume(resp.getEntity()); throw new IOException("Response code: " + statusCode + " for " + base); } String respBody = EntityUtils.toString(resp.getEntity()); Document baseDoc = OSLCUtils.createXMLDocFromResponseBody(respBody); // ArrayList to contain the urls from all SPCs Collection<Object[]> data = new ArrayList<Object[]>(); Node rootElement = (Node) OSLCUtils.getXPath().evaluate("/rdf:RDF/*", baseDoc, XPathConstants.NODE); if (rootElement.getNamespaceURI().equals(OSLCConstants.OSLC_V2) && rootElement.getLocalName().equals("ServiceProviderCatalog")) { data.add(new Object[] { base }); } // Get all ServiceProviderCatalog urls from the base document in order // to test them as well, // recursively checking them for other ServiceProviderCatalogs further // down. NodeList spcs = (NodeList) OSLCUtils.getXPath().evaluate( "//oslc_v2:serviceProviderCatalog/oslc_v2:ServiceProviderCatalog/@rdf:about", baseDoc, XPathConstants.NODESET); for (int i = 0; i < spcs.getLength(); i++) { if (!spcs.item(i).getNodeValue().equals(base)) { Collection<Object[]> subCollection = getReferencedCatalogUrlsUsingXML(spcs.item(i).getNodeValue()); Iterator<Object[]> iter = subCollection.iterator(); while (iter.hasNext()) { data.add(iter.next()); } } } return data; }
From source file:com.microsoft.tfs.util.xml.DOMUtils.java
/** * Tests whether the given {@link Node} matches the specified name. No * <code>null</code> checking is done of the <code>node</code> argument. * * @param node// www. j a va 2 s . co m * the {@link Node} to test (must not be <code>null</code>) * @param useNamespaces * <code>true</code> for namespaces mode * @param namespaceURI * the namespace URI to match, <code>null</code> to match no * namespace, <code>*</code> to match any namespace (ignored if * <code>useNamespaces</code> is <code>false</code>) * @param localName * <code>null</code> or <code>*</code> to match any node, matches the * node name if <code>useNamespaces</code> is <code>false</code>, * matches the local name if <code>useNamespaces</code> is * <code>true</code> * @return <code>true</code> if the {@link Node} matches the criteria */ private static boolean matches(final Node node, final boolean useNamespaces, final String namespaceURI, final String localName) { if (useNamespaces) { if (namespaceURI == null && node.getNamespaceURI() != null) { return false; } if (namespaceURI != null && !namespaceURI.equals("*") && !namespaceURI.equals(node.getNamespaceURI())) //$NON-NLS-1$ { return false; } } if (localName == null || localName.equals("*")) //$NON-NLS-1$ { return true; } if (useNamespaces) { return localName.equals(node.getLocalName()); } return localName.equals(node.getNodeName()); }
From source file:jp.go.nict.langrid.bpel.ProcessAnalyzer.java
/** * /*ww w. j a va 2 s . c om*/ * */ public static BPEL analyzeBPEL(byte[] body) throws SAXException, URISyntaxException, XPathExpressionException { Document doc; try { doc = builder.parse(new ByteArrayInputStream(body)); } catch (IOException e) { throw new RuntimeException(e); } Node root = doc.getDocumentElement(); NamespaceContextImpl nsc = new NamespaceContextImpl(); addNamespaceMappings(nsc, root.getAttributes()); String rootNs = root.getNamespaceURI(); nsc.addMapping("_", rootNs); XPath xpath = DocumentUtil.getDefaultXPath(); xpath.setNamespaceContext(nsc); String processName = NodeUtil.getAttribute(root, "name"); BPEL bpel = new BPEL(); bpel.setBody(body); if (rootNs.equals(bpel4ws_1_1_ns)) { bpel.setBpelVersion(BPELVersion.BPEL4WS_1_1); } else if (rootNs.equals(wsbpel_2_0_ns)) { bpel.setBpelVersion(BPELVersion.WSBPEL_2_0); } else { bpel.setBpelVersion(BPELVersion.UNKNOWN); } bpel.setTargetNamespace(new URI(xpath.evaluate("/_:process/@targetNamespace", root))); bpel.setProcessName(processName); bpel.setFilename(processName + BPEL_EXTENSION); ArrayList<PartnerLink> links = new ArrayList<PartnerLink>(); NodeList list = (NodeList) xpath.evaluate("/_:process/_:partnerLinks/_:partnerLink", root, XPathConstants.NODESET); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); PartnerLink pl = new PartnerLink(nsc, node); links.add(pl); } bpel.setPartnerLinks(links); return bpel; }
From source file:gov.nist.healthcare.ttt.parsing.Parsing.java
public static String getPatientIDFromWsse(String mtom) throws IOException, MessagingException, SAXException, ParserConfigurationException { String wsseHeader = Parsing.getWsseHeaderFromMTOM(mtom); if (wsseHeader == null) return ""; // NOSAML String patientId = null;//from w w w . j a v a 2 s .c o m // Node security = JAXB.unmarshal(new StringReader(wsseHeader), Node.class); Node securityDoc = MiscUtil.stringToDom(wsseHeader); Node security = securityDoc.getFirstChild(); NodeList securityChildren = security.getChildNodes(); for (int i = 0; i < securityChildren.getLength(); i++) { Node securityChild = securityChildren.item(i); if (securityChild.getLocalName() != null && securityChild.getLocalName().equals("Assertion") && securityChild.getNamespaceURI().equals("urn:oasis:names:tc:SAML:2.0:assertion")) { Node assertion = securityChild; NodeList assertionChildren = assertion.getChildNodes(); for (int j = 0; j < assertionChildren.getLength(); j++) { Node assertionChild = assertionChildren.item(j); if (assertionChild.getLocalName().equals("AttributeStatement") && assertionChild.getNamespaceURI().equals("urn:oasis:names:tc:SAML:2.0:assertion")) { Node attributeStatement = assertionChild; NodeList attributeStatementChildren = attributeStatement.getChildNodes(); for (int k = 0; k < attributeStatementChildren.getLength(); k++) { Node attributeStatementChild = attributeStatementChildren.item(k); if (attributeStatementChild.getLocalName().equals("Attribute") && attributeStatementChild.getNamespaceURI() .equals("urn:oasis:names:tc:SAML:2.0:assertion")) { Element attribute = (Element) attributeStatementChild; if (attribute.getAttribute("Name") .equals("urn:oasis:names:tc:xacml:2.0:resource:resource-id")) { NodeList attributeChildren = attribute.getChildNodes(); for (int l = 0; l < attributeChildren.getLength(); l++) { Node attributeChild = attributeChildren.item(l); if (attributeChild.getLocalName().equals("AttributeValue") && attributeChild.getNamespaceURI() .equals("urn:oasis:names:tc:SAML:2.0:assertion")) { Node attributeValue = attributeChild; return attributeValue.getFirstChild().getNodeValue(); } } } } } } } } } return patientId; }
From source file:Main.java
private static boolean isEqualNode(Node arg0, Node arg) { if (arg == arg0) { return true; }/* ww w.jav a2 s . co m*/ if (arg.getNodeType() != arg0.getNodeType()) { return false; } if (arg0.getNodeName() == null) { if (arg.getNodeName() != null) { return false; } } else if (!arg0.getNodeName().equals(arg.getNodeName())) { return false; } if (arg0.getLocalName() == null) { if (arg.getLocalName() != null) { return false; } } else if (!arg0.getLocalName().equals(arg.getLocalName())) { return false; } if (arg0.getNamespaceURI() == null) { if (arg.getNamespaceURI() != null) { return false; } } else if (!arg0.getNamespaceURI().equals(arg.getNamespaceURI())) { return false; } if (arg0.getPrefix() == null) { if (arg.getPrefix() != null) { return false; } } else if (!arg0.getPrefix().equals(arg.getPrefix())) { return false; } if (arg0.getNodeValue() == null) { if (arg.getNodeValue() != null) { return false; } } else if (!arg0.getNodeValue().equals(arg.getNodeValue())) { return false; } return true; }
From source file:org.escidoc.browser.elabsmodul.service.ELabsService.java
private static InvestigationBean resolveInvestigation(final ContainerProxy containerProxy) { final String URI_DC = "http://purl.org/dc/elements/1.1/"; final String URI_EL = "http://escidoc.org/ontologies/bw-elabs/re#"; final String URI_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; if (containerProxy == null) { throw new NullPointerException("Container Proxy is null."); }/* w ww. j a v a 2s . c o m*/ final InvestigationBean investigationBean = new InvestigationBean(); final Element e = containerProxy.getMetadataRecords().get("escidoc").getContent(); investigationBean.setObjid(containerProxy.getId()); if (!(("Investigation".equals(e.getLocalName()) && URI_EL.equals(e.getNamespaceURI())) || "el:Investigation".equals(e.getTagName()))) { LOG.error("Container is not an eLabs Investigation"); return investigationBean; } final NodeList nodeList = e.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { final Node node = nodeList.item(i); final String nodeName = node.getLocalName(); final String nsUri = node.getNamespaceURI(); if (nodeName == null || nsUri == null) { continue; } if ("title".equals(nodeName) && URI_DC.equals(nsUri)) { investigationBean.setName(node.getTextContent()); } else if ("description".equals(nodeName) && URI_DC.equals(nsUri)) { investigationBean.setDescription(node.getTextContent()); } else if ("max-runtime".equals(nodeName) && URI_EL.equals(nsUri)) { investigationBean.setMaxRuntime("<<not used>>"); try { investigationBean.setMaxRuntimeInMin(Integer.valueOf(node.getTextContent())); } catch (final NumberFormatException nfe) { LOG.error(nfe.getMessage()); investigationBean.setMaxRuntimeInMin(0); } } else if ("deposit-endpoint".equals(nodeName) && URI_EL.equals(nsUri)) { investigationBean.setDepositEndpoint(node.getTextContent()); } else if ("investigator".equals(nodeName) && URI_EL.equals(nsUri)) { final String investigatorId = node.getAttributes().getNamedItemNS(URI_RDF, "resource") .getTextContent(); investigationBean.setInvestigator(investigatorId); } else if ("rig".equals(nodeName) && URI_EL.equals(nsUri)) { final String rigId = node.getAttributes().getNamedItemNS(URI_RDF, "resource").getTextContent(); if (StringUtils.notEmpty(rigId)) { final RigBean rigBean = new RigBean(); rigBean.setObjectId(rigId); investigationBean.setRigBean(rigBean); } } else if ("instrument".equals(nodeName) && URI_EL.equals(nsUri)) { final String instrument = node.getAttributes().getNamedItemNS(URI_RDF, "resource").getTextContent(); final String folder = node.getTextContent().trim(); investigationBean.getInstrumentFolder().put(instrument, folder); } } return investigationBean; }
From source file:org.escidoc.browser.elabsmodul.service.ELabsService.java
private static InstrumentBean resolveInstrument(final ResourceProxy resourceProxy) throws EscidocBrowserException { if (resourceProxy == null || !(resourceProxy instanceof ItemProxy)) { throw new EscidocBrowserException("NOT an ItemProxy", null); }/*from www.j a va 2 s . c om*/ final ItemProxy itemProxy = (ItemProxy) resourceProxy; final InstrumentBean instrumentBean = new InstrumentBean(); instrumentBean.setObjectId(itemProxy.getId()); final Element e = itemProxy.getMetadataRecords().get("escidoc").getContent(); final NodeList nodeList = e.getChildNodes(); final String URI_DC = "http://purl.org/dc/elements/1.1/"; final String URI_EL = "http://escidoc.org/ontologies/bw-elabs/re#"; for (int i = 0; i < nodeList.getLength(); i++) { final Node node = nodeList.item(i); final String nodeName = node.getLocalName(); final String nsUri = node.getNamespaceURI(); if (nodeName == null || nodeName.equals("")) { continue; } else if (nsUri == null || nsUri.equals("")) { continue; } if ("title".equals(nodeName) && URI_DC.equals(nsUri)) { instrumentBean.setName((node.getFirstChild() != null) ? node.getFirstChild().getNodeValue() : null); } else if ("description".equals(nodeName) && URI_DC.equals(nsUri)) { instrumentBean.setDescription( (node.getFirstChild() != null) ? node.getFirstChild().getNodeValue() : null); } else if ("requires-configuration".equals(nodeName) && URI_EL.equals(nsUri)) { final String value = node.getFirstChild().getNodeValue(); if (value.equals("no")) { instrumentBean.setConfiguration(false); } else if (value.equals("yes")) { instrumentBean.setConfiguration(true); } } else if ("requires-calibration".equals(nodeName) && URI_EL.equals(nsUri)) { final String value = node.getFirstChild().getNodeValue(); if (value.equals("no")) { instrumentBean.setCalibration(false); } else if (value.equals("yes")) { instrumentBean.setCalibration(true); } } else if ("esync-endpoint".equals(nodeName) && URI_EL.equals(nsUri)) { instrumentBean.setESyncDaemon( (node.getFirstChild() != null) ? node.getFirstChild().getNodeValue() : null); } else if ("monitored-folder".equals(nodeName) && URI_EL.equals(nsUri)) { instrumentBean .setFolder((node.getFirstChild() != null) ? node.getFirstChild().getNodeValue() : null); } else if ("result-mime-type".equals(nodeName) && URI_EL.equals(nsUri)) { instrumentBean .setFileFormat((node.getFirstChild() != null) ? node.getFirstChild().getNodeValue() : null); } else if ("responsible-person".equals(nodeName) && URI_EL.equals(nsUri) && node.getAttributes().getNamedItem("rdf:resource") != null) { final String supervisorId = node.getAttributes().getNamedItem("rdf:resource").getNodeValue(); instrumentBean.setDeviceSupervisor(supervisorId); } else if ("institution".equals(nodeName) && URI_EL.equals(nsUri) && node.getAttributes().getNamedItem("rdf:resource") != null) { final String instituteId = node.getAttributes().getNamedItem("rdf:resource").getNodeValue(); instrumentBean.setInstitute(instituteId); } } return instrumentBean; }
From source file:com.centeractive.ws.SchemaUtils.java
/** * Returns a map mapping urls to corresponding XmlSchema XmlObjects for the * specified wsdlUrl/* w w w . ja v a 2 s . com*/ */ public static void getSchemas(String wsdlUrl, Map<String, XmlObject> existing, SchemaLoader loader, String tns, String xml) { if (existing.containsKey(wsdlUrl)) { return; } log.debug("Getting schema " + wsdlUrl); ArrayList<?> errorList = new ArrayList<Object>(); Map<String, XmlObject> result = new HashMap<String, XmlObject>(); boolean common = false; try { XmlOptions options = new XmlOptions(); options.setCompileNoValidation(); options.setSaveUseOpenFrag(); options.setErrorListener(errorList); options.setSaveSyntheticDocumentElement(new QName(Constants.XSD_NS, "schema")); XmlObject xmlObject = loader.loadXmlObject(xml); if (xmlObject == null) throw new Exception("Failed to load schema from [" + wsdlUrl + "]"); Document dom = (Document) xmlObject.getDomNode(); Node domNode = dom.getDocumentElement(); // is this an xml schema? if (domNode.getLocalName().equals("schema") && Constants.XSD_NS.equals(domNode.getNamespaceURI())) { // set targetNamespace (this happens if we are following an include // statement) if (tns != null) { Element elm = ((Element) domNode); if (!elm.hasAttribute("targetNamespace")) { common = true; elm.setAttribute("targetNamespace", tns); } // check for namespace prefix for targetNamespace NamedNodeMap attributes = elm.getAttributes(); int c = 0; for (; c < attributes.getLength(); c++) { Node item = attributes.item(c); if (item.getNodeName().equals("xmlns")) break; if (item.getNodeValue().equals(tns) && item.getNodeName().startsWith("xmlns")) break; } if (c == attributes.getLength()) elm.setAttribute("xmlns", tns); } if (common && !existing.containsKey(wsdlUrl + "@" + tns)) result.put(wsdlUrl + "@" + tns, xmlObject); else result.put(wsdlUrl, xmlObject); } else { existing.put(wsdlUrl, null); XmlObject[] schemas = xmlObject .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:schema"); for (int i = 0; i < schemas.length; i++) { XmlCursor xmlCursor = schemas[i].newCursor(); String xmlText = xmlCursor.getObject().xmlText(options); // schemas[i] = XmlObject.Factory.parse( xmlText, options ); schemas[i] = XmlUtils.createXmlObject(xmlText, options); schemas[i].documentProperties().setSourceName(wsdlUrl); result.put(wsdlUrl + "@" + (i + 1), schemas[i]); } XmlObject[] wsdlImports = xmlObject .selectPath("declare namespace s='" + Constants.WSDL11_NS + "' .//s:import/@location"); for (int i = 0; i < wsdlImports.length; i++) { String location = ((SimpleValue) wsdlImports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null, xml); } } XmlObject[] wadl10Imports = xmlObject.selectPath( "declare namespace s='" + Constants.WADL10_NS + "' .//s:grammars/s:include/@href"); for (int i = 0; i < wadl10Imports.length; i++) { String location = ((SimpleValue) wadl10Imports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null, xml); } } XmlObject[] wadlImports = xmlObject.selectPath( "declare namespace s='" + Constants.WADL11_NS + "' .//s:grammars/s:include/@href"); for (int i = 0; i < wadlImports.length; i++) { String location = ((SimpleValue) wadlImports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null, xml); } } } existing.putAll(result); XmlObject[] schemas = result.values().toArray(new XmlObject[result.size()]); for (int c = 0; c < schemas.length; c++) { xmlObject = schemas[c]; XmlObject[] schemaImports = xmlObject .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:import/@schemaLocation"); for (int i = 0; i < schemaImports.length; i++) { String location = ((SimpleValue) schemaImports[i]).getStringValue(); Element elm = ((Attr) schemaImports[i].getDomNode()).getOwnerElement(); if (location != null && !defaultSchemas.containsKey(elm.getAttribute("namespace"))) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null, xml); } } XmlObject[] schemaIncludes = xmlObject .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:include/@schemaLocation"); for (int i = 0; i < schemaIncludes.length; i++) { String location = ((SimpleValue) schemaIncludes[i]).getStringValue(); if (location != null) { String targetNS = getTargetNamespace(xmlObject); if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, targetNS, xml); } } } } catch (Exception e) { throw new SoapBuilderException(e); } }
From source file:com.example.soaplegacy.SchemaUtils.java
/** * Returns a map mapping urls to corresponding XmlSchema XmlObjects for the * specified wsdlUrl/*from w ww . j a va2 s . c o m*/ */ public static void getSchemas(String wsdlUrl, Map<String, XmlObject> existing, SchemaLoader loader, String tns) { if (existing.containsKey(wsdlUrl)) { return; } log.debug("Getting schema " + wsdlUrl); ArrayList<?> errorList = new ArrayList<Object>(); Map<String, XmlObject> result = new HashMap<String, XmlObject>(); boolean common = false; try { XmlOptions options = new XmlOptions(); options.setCompileNoValidation(); options.setSaveUseOpenFrag(); options.setErrorListener(errorList); options.setSaveSyntheticDocumentElement(new QName(Constants.XSD_NS, "schema")); XmlObject xmlObject = loader.loadXmlObject(wsdlUrl, options); if (xmlObject == null) throw new Exception("Failed to load schema from [" + wsdlUrl + "]"); Document dom = (Document) xmlObject.getDomNode(); Node domNode = dom.getDocumentElement(); // is this an xml schema? if (domNode.getLocalName().equals("schema") && Constants.XSD_NS.equals(domNode.getNamespaceURI())) { // set targetNamespace (this happens if we are following an include // statement) if (tns != null) { Element elm = ((Element) domNode); if (!elm.hasAttribute("targetNamespace")) { common = true; elm.setAttribute("targetNamespace", tns); } // check for namespace prefix for targetNamespace NamedNodeMap attributes = elm.getAttributes(); int c = 0; for (; c < attributes.getLength(); c++) { Node item = attributes.item(c); if (item.getNodeName().equals("xmlns")) break; if (item.getNodeValue().equals(tns) && item.getNodeName().startsWith("xmlns")) break; } if (c == attributes.getLength()) elm.setAttribute("xmlns", tns); } if (common && !existing.containsKey(wsdlUrl + "@" + tns)) result.put(wsdlUrl + "@" + tns, xmlObject); else result.put(wsdlUrl, xmlObject); } else { existing.put(wsdlUrl, null); XmlObject[] schemas = xmlObject .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:schema"); for (int i = 0; i < schemas.length; i++) { XmlCursor xmlCursor = schemas[i].newCursor(); String xmlText = xmlCursor.getObject().xmlText(options); // schemas[i] = XmlObject.Factory.parse( xmlText, options ); schemas[i] = XmlUtils.createXmlObject(xmlText, options); schemas[i].documentProperties().setSourceName(wsdlUrl); result.put(wsdlUrl + "@" + (i + 1), schemas[i]); } XmlObject[] wsdlImports = xmlObject .selectPath("declare namespace s='" + Constants.WSDL11_NS + "' .//s:import/@location"); for (int i = 0; i < wsdlImports.length; i++) { String location = ((SimpleValue) wsdlImports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } XmlObject[] wadl10Imports = xmlObject.selectPath( "declare namespace s='" + Constants.WADL10_NS + "' .//s:grammars/s:include/@href"); for (int i = 0; i < wadl10Imports.length; i++) { String location = ((SimpleValue) wadl10Imports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } XmlObject[] wadlImports = xmlObject.selectPath( "declare namespace s='" + Constants.WADL11_NS + "' .//s:grammars/s:include/@href"); for (int i = 0; i < wadlImports.length; i++) { String location = ((SimpleValue) wadlImports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } } existing.putAll(result); XmlObject[] schemas = result.values().toArray(new XmlObject[result.size()]); for (int c = 0; c < schemas.length; c++) { xmlObject = schemas[c]; XmlObject[] schemaImports = xmlObject .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:import/@schemaLocation"); for (int i = 0; i < schemaImports.length; i++) { String location = ((SimpleValue) schemaImports[i]).getStringValue(); Element elm = ((Attr) schemaImports[i].getDomNode()).getOwnerElement(); if (location != null && !defaultSchemas.containsKey(elm.getAttribute("namespace"))) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } XmlObject[] schemaIncludes = xmlObject .selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:include/@schemaLocation"); for (int i = 0; i < schemaIncludes.length; i++) { String location = ((SimpleValue) schemaIncludes[i]).getStringValue(); if (location != null) { String targetNS = getTargetNamespace(xmlObject); if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, targetNS); } } } } catch (Exception e) { throw new SoapBuilderException(e); } }
From source file:eu.semaine.util.XMLTool.java
/** * Create a node iterator for the current document, which will provide exactly * the elements below root in the given namespace whose local names are in localNames. * This is independent of any namespace prefixes. * @param doc/*from w ww . ja va 2 s . c om*/ * @param root * @param namespaceURI * @param localNames the array of local names to be accepted. * @return */ public static NodeIterator createNodeIterator(Document doc, Node root, final String namespaceURI, final String... localNames) { NodeIterator ni = ((DocumentTraversal) doc).createNodeIterator(root, NodeFilter.SHOW_ELEMENT, new NodeFilter() { @Override public short acceptNode(Node n) { if (!isSameNamespace(n.getNamespaceURI(), namespaceURI)) { return NodeFilter.FILTER_SKIP; } for (String localName : localNames) { if (localName.equals(n.getLocalName())) { return NodeFilter.FILTER_ACCEPT; } } return NodeFilter.FILTER_SKIP; } }, false); return ni; }