public TemplateFactory(Map<String, String> namespaces) { context = XMLPathCtx.createNew(); context.addNamespaces(namespaces); }
public XPathContextFactory(Map<String, String> namespaces) { xmlPathCtx = XMLPathCtx.createNew(); xmlPathCtx.addNamespaces(namespaces); }
public void debugPDPRequest(final Element request) { StringBuilder text = new StringBuilder(); NodeList requestChildNodes = XMLPathCtx.createNew().findIn(request).all("/*[local-name() = 'Request']/*").get(); for (int i = 0; i < requestChildNodes.getLength(); i++) { Element requestChild = (Element) requestChildNodes.item(i); text.append(requestChild.getLocalName()).append("\n"); appendAttributes(text, XMLPathCtx.createNew().findIn(requestChild).all(".//*[local-name()='AttributeValue']").get()); } LOG.debug("PDP request\n" + text); }
XACML2ResponseChunkHandler(List<ResponseDocument> responseSet) { m_responseSet = responseSet; xmlPathCtx = XMLPathCtx.createNew(); xmlPathCtx.addNamespace("c", "urn:oasis:names:tc:xacml:2.0:context:schema:os").addNamespace("p", "urn:oasis:names:tc:xacml:2.0:policy:schema:os"); }
private void debugPDPResponse(Element response) { StringBuilder text = new StringBuilder(); String resourceId = XMLPathCtx.createNew().findIn(response).text("//*[local-name() = 'Result']/@ResourceId").get(); String decision = XMLPathCtx.createNew().findIn(response).text("//*[local-name() = 'Result']/*[local-name() = 'Decision']/text()").get(); text.append("Resource: \t").append(resourceId ).append("\n"); text.append("Decision: \t").append(decision).append("\n"); NodeList obligationNodes = XMLPathCtx.createNew().findIn(response).all("//*[local-name() = 'Obligation']").get(); for (int i = 0; i < obligationNodes.getLength(); i++) { Element obligationElem = (Element) obligationNodes.item(i); String oblId = obligationElem.getAttribute("ObligationId"); String fulfillOn = obligationElem.getAttribute("FulfillOn"); text.append("Obligation: \t").append(oblId ).append("(fulfillOn:").append(fulfillOn).append(")\n"); appendAttributeAssignments(text, XMLPathCtx.createNew().findIn(obligationElem).all(".//*[local-name()='AttributeAssignment']").get()); } LOG.debug("PDP response\n" + text); }
/** * Class constructor. * <p/> * <p> * Within this initialization, the classloader searches the xml configuration file <br> * called 'catalog_api_factory.xml' that needs to be in the classpath. If not, the <br> * initialization of the factory fails. * </p> */ public BuilderFactory() { InputStream is = BuilderFactory.class.getResourceAsStream("/catalog_api_factory.xml"); if (is != null) { mRoot = DOMUtil.createFromStream(is, null); xmlPathCtx = XMLPathCtx.createNew(); xmlPathCtx.addNamespace("api", "http://www.conterra.de/catalog/config/catapi"); } else { LOG.error("Could not find 'catalog_api_factory.xml' in CLASSPATH. BuilderFactory is not available"); mRoot = null; } }
public List<SAML2IdPMetadata> getIdPMetadata() { XMLPathCtx xpathCtx = XMLPathCtx.createNew().addNamespace("md", "urn:oasis:names:tc:SAML:2.0:metadata"); NodeList idpList = xpathCtx.findIn(m_federationMetadata).all("//md:IDPSSODescriptor").get(); List<SAML2IdPMetadata> mdList = new ArrayList<SAML2IdPMetadata>(); for (int i = 0; i < idpList.getLength(); i++) { Element idpSsoDescriptor = (Element) idpList.item(i); try { SAML2IdPMetadata idPMetadata = SAML2IdPMetadata.createFrom(idpSsoDescriptor); mdList.add(idPMetadata); } catch (MalformedURLException e) { LOG.error("Skipping IDPSSODescriptor element", e); } } return mdList; }
XMLPathCtx.createNew().addNamespace("ows", "http://www.opengis.net/ows/1.1") .addNamespace("sos", "http://www.opengis.net/sos/1.0");
public PAOSResponse(Element paosResponse) { m_paosResponse = paosResponse; setXpathCtx(XMLPathCtx.createNew().addNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol").addNamespace( "ecp", "urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp")); }
private Node find(final String xpath) { Node node = XMLPathCtx.createNew().addNamespaces(namespaces).findIn(sourceDocument).node(xpath).get(); if (node == null) { throw new IllegalArgumentException("XPath <" + xpath + "> must resolve to an node"); } return (Element) node; }
public Payload replace(String pOldURL, Transferable res, String pEncoding, String pMimeType) { Document doc = DOMParser.createNew().parse(new InputSource(res.getPayload().getAsStream())); XMLPathCtx ctx = XMLPathCtx.createNew(); NodeList nodes = ctx.findIn(doc).all("//OnlineResource").get(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getParentNode().getParentNode().getLocalName().equals("HTTP")) { String name = node.getParentNode().getLocalName(); node.getParentNode().getParentNode().replaceChild(buildReplacement(name, doc), node.getParentNode()); } } // WMS 1.? // TODO extend XPath for POST nodes: //DCPType/HTTP/*[self::Get // or self::Post]/OnlineResource // WFS 1.1 // TODO extend XPath for POST nodes: // //ows:Operation/ows:DCP/ows:HTTP/*[self::ows:Get or // self::ows:Post] // WFS 1.0 // TODO add XPath for WFS 1.0.0: //DCPType/HTTP/*[self::Get or // self::Post]/@onlineResource DOMSerializer serializer = DOMSerializer.createNew(); String response = serializer.serializeToString(doc); Pattern lPattern = Pattern.compile(pOldURL.replaceAll("\\?", "\\\\?")); Matcher mMatcher = lPattern.matcher(response); response = mMatcher.replaceAll(m_gatekeeperURL); sLogger.debug("Modified ResponseDocument:\n" + response); return new TextualPayload(response, pEncoding); }
XMLPathCtx.createNew().addNamespace("ows", "http://www.opengis.net/ows/1.1") .addNamespace("sos", "http://www.opengis.net/sos/1.0");
/** * Creates an instance of this class from an XML file. * * @param in * a service excpetion XML document * * @return * @throws org.xml.sax.SAXException * @throws IOException */ public static ServiceException createFromXML(InputSource in) { Document excDoc = DOMParser.createNew().parse(in); XMLPathCtx pathCtx = XMLPathCtx.createNew(); String cd = pathCtx.findIn(excDoc).text("//ServiceException/@code").get().trim(); if (cd.equals("")) cd = "No code available"; String msg = pathCtx.findIn(excDoc).text("//ServiceException/text()").get().trim(); if (msg.equals("")) msg = "No exception information available"; return new ServiceException(msg, cd); }
= XMLPathCtx.createNew().addNamespace("ows", "http://www.opengis.net/ows/1.1").addNamespace("wfs", "http://www.opengis.net/wfs/1.0.0");
XMLPathCtx.createNew().addNamespace("ows", "http://www.opengis.net/ows/1.1").addNamespace("wps", "http://www.opengis.net/wps/1.0.0");
XMLPathCtx.createNew().addNamespace("sos", "http://www.opengis.net/sos/1.0") .addNamespace("gml", "http://www.opengis.net/gml");
isXMLRequest = true; ctx = XMLPathCtx.createNew().addNamespace("ows", "http://www.opengis.net/ows/1.1").addNamespace("wfs", "http://www.opengis.net/wfs/1.0.0").addNamespace("ogc", "http://www.opengis.net/ogc");
public static SAML2IdPMetadata createFrom(Element idpSsoDescrElement) throws MalformedURLException { XMLPathCtx xpathCtx = XMLPathCtx.createNew().addNamespace("md", "urn:oasis:names:tc:SAML:2.0:metadata"); NodeList nodeList = xpathCtx.findIn(idpSsoDescrElement).all("md:SingleSignOnService").get(); SAML2IdPMetadata metadata = new SAML2IdPMetadata(); for (int i = 0; i < nodeList.getLength(); i++) { Element ssoService = (Element) nodeList.item(i); String binding = ssoService.getAttribute("Binding"); String location = ssoService.getAttribute("Location"); metadata.addSSOBinding(binding, new URL(location)); } Element organizationElem = (Element) xpathCtx.findIn(idpSsoDescrElement).node("./../md:Organization").get(); if (organizationElem == null) { String entityID = xpathCtx.findIn(idpSsoDescrElement).text("./../@entityID").get(); metadata.setOrganisationDisplayName(entityID); } else { String idpDisplayName = xpathCtx.findIn(organizationElem).text("md:OrganizationDisplayName/text()").get(); metadata.setOrganisationDisplayName(idpDisplayName); } return metadata; }
XMLPathCtx.createNew().addNamespace("ows", "http://www.opengis.net/ows/1.1").addNamespace("wps", "http://www.opengis.net/wps/1.0.0");
private WSSCapabilitiesDocument(Document capsDoc) { m_capsDoc = capsDoc; m_xPathCtx = XMLPathCtx.createNew(); m_xPathCtx.addNamespace("authn", "http://www.gdi-nrw.org/authn"); m_xPathCtx.addNamespace("xlink", "http://www.w3.org/1999/xlink"); m_xPathCtx.addNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); m_xPathCtx.addNamespace("licb", "http://www.conterra.de/licb"); m_xPathCtx.addNamespace("ows", "http://www.opengis.net/ows"); m_xPathCtx.addNamespace("wss", "http://www.gdi-nrw.org/wss"); m_editor = new Editor(); m_parser = new Parser(); }