List of usage examples for org.w3c.dom Node getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:org.apache.xml.security.keys.KeyInfo.java
/** * Method itemUnknownElement/* ww w. jav a 2 s . c om*/ * * @param i index * @return the element number of the unknown elements */ public Element itemUnknownElement(int i) { NodeList nl = this.constructionElement.getChildNodes(); int res = 0; for (int j = 0; j < nl.getLength(); j++) { Node current = nl.item(j); /** * $todo$ using this method, we don't see unknown Elements * from Signature NS; revisit */ if ((current.getNodeType() == Node.ELEMENT_NODE) && current.getNamespaceURI().equals(Constants.SignatureSpecNS)) { res++; if (res == i) { return (Element) current; } } } return null; }
From source file:org.apache.xml.security.utils.ElementProxy.java
/** * Method length//w ww.j a v a 2 s. c o m * * @param namespace * @param localname * @return the number of elements {namespace}:localname under this element */ public int length(String namespace, String localname) { int number = 0; Node sibling = this.constructionElement.getFirstChild(); while (sibling != null) { if (localname.equals(sibling.getLocalName()) && namespace.equals(sibling.getNamespaceURI())) { number++; } sibling = sibling.getNextSibling(); } return number; }
From source file:org.apache.xml.security.utils.XMLUtils.java
/** * @param sibling/*from www . jav a 2s . co m*/ * @param nodeName * @param number * @return nodes with the constraint */ public static Element selectDsNode(Node sibling, String nodeName, int number) { while (sibling != null) { if (Constants.SignatureSpecNS.equals(sibling.getNamespaceURI()) && sibling.getLocalName().equals(nodeName)) { if (number == 0) { return (Element) sibling; } number--; } sibling = sibling.getNextSibling(); } return null; }
From source file:org.apache.xml.security.utils.XMLUtils.java
/** * @param sibling//from www.j av a 2 s . c o m * @param nodeName * @param number * @return nodes with the constrain */ public static Element selectXencNode(Node sibling, String nodeName, int number) { while (sibling != null) { if (EncryptionConstants.EncryptionSpecNS.equals(sibling.getNamespaceURI()) && sibling.getLocalName().equals(nodeName)) { if (number == 0) { return (Element) sibling; } number--; } sibling = sibling.getNextSibling(); } return null; }
From source file:org.apereo.portal.io.xml.PortalDataKey.java
public PortalDataKey(Node rootElement) { if (rootElement.getNodeType() == Node.DOCUMENT_NODE) { rootElement = ((Document) rootElement).getDocumentElement(); }//w ww. j a v a2 s . c om final String nodeName = rootElement.getNodeName(); final String namespaceURI = rootElement.getNamespaceURI(); if (namespaceURI != null) { this.name = new QName(namespaceURI, nodeName); } else { this.name = new QName(nodeName); } final NamedNodeMap attributes = rootElement.getAttributes(); if (attributes != null) { final Node scriptAttr = attributes.getNamedItem(SCRIPT_ATTRIBUTE_NAME.getLocalPart()); if (scriptAttr != null) { this.script = scriptAttr.getTextContent(); } else { this.script = null; } final Node versionAttr = attributes.getNamedItem(VERSION_ATTRIBUTE_NAME.getLocalPart()); if (versionAttr != null) { this.version = versionAttr.getTextContent(); } else { this.version = null; } } else { this.script = null; this.version = null; } }
From source file:org.chiba.xml.xforms.Model.java
private void loadInlineSchemas(List list) throws XFormsException { String schemaId = null;//from w w w . jav a2 s. c o m try { NodeList children = this.element.getChildNodes(); for (int index = 0; index < children.getLength(); index++) { Node child = children.item(index); if (Node.ELEMENT_NODE == child.getNodeType() && NamespaceCtx.XMLSCHEMA_NS.equals(child.getNamespaceURI())) { Element element = (Element) child; schemaId = element.hasAttributeNS(null, "id") ? element.getAttributeNS(null, "id") : element.getNodeName(); XSModel schema = loadSchema(element); if (schema == null) { throw new NullPointerException("resource not found"); } list.add(schema); } } } catch (Exception e) { throw new XFormsLinkException("could not load inline schema", this.target, schemaId); } }
From source file:org.chiba.xml.xforms.ui.Switch.java
/** * Initializes the Case elements./*from w ww .j av a 2s.c o m*/ * <p/> * If multiple Cases within a Switch are selected, the first selected Case * remains and all others are deselected. If none are selected, the first * becomes selected. */ protected final void initializeSwitch() throws XFormsException { NodeList childNodes = getElement().getChildNodes(); List cases = new ArrayList(childNodes.getLength()); Node node; Case caseElement; String selectedAttribute; int selection = -1; for (int index = 0; index < childNodes.getLength(); index++) { node = childNodes.item(index); if (node.getNodeType() == Node.ELEMENT_NODE && NamespaceConstants.XFORMS_NS.equals(node.getNamespaceURI()) && CASE.equals(node.getLocalName())) { caseElement = (Case) ((NodeImpl) node).getUserData(); cases.add(caseElement); selectedAttribute = caseElement.getXFormsAttribute(SELECTED_ATTRIBUTE); if ((selection == -1) && ("true").equals(selectedAttribute)) { // keep *first* selected case position selection = cases.size() - 1; } } } if (selection == -1) { if (getLogger().isDebugEnabled()) { getLogger().debug(this + " init: choosing first case for selection by default"); } // select first case if none is selected selection = 0; } // perform selection/deselection for (int index = 0; index < cases.size(); index++) { caseElement = (Case) cases.get(index); if (index == selection) { if (getLogger().isDebugEnabled()) { getLogger().debug(this + " init: selecting case '" + caseElement.getId() + "'"); } caseElement.select(); } else { if (getLogger().isDebugEnabled()) { getLogger().debug(this + " init: deselecting case '" + caseElement.getId() + "'"); } caseElement.deselect(); } } // set state for updateSwitch() this.initAfterReady = this.model.isReady(); }
From source file:org.chiba.xml.xforms.xpath.test.InstanceFactoryTest.java
private void assertElement(Node node, String localName, String namespaceURI, int children) { assertNotNull(node);//from www . j ava 2 s .c o m assertEquals(Node.ELEMENT_NODE, node.getNodeType()); assertEquals(localName, node.getLocalName()); assertEquals(namespaceURI, node.getNamespaceURI()); assertEquals(children, node.getChildNodes().getLength()); }
From source file:org.chiba.xml.xforms.xpath.test.InstanceFactoryTest.java
private void assertNamespaceDeclarations(Node node) { assertNotNull(node);/* w ww . jav a 2 s. c om*/ assertEquals(Node.ELEMENT_NODE, node.getNodeType()); NamedNodeMap attributes = node.getAttributes(); int nsDeclarations = 0; for (int i = 0; i < attributes.getLength(); i++) { Node attr = attributes.item(i); if (NamespaceCtx.XMLNS_NS.equals(attr.getNamespaceURI())) { nsDeclarations++; } } assertEquals(7, nsDeclarations); assertEquals("", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "xmlns").getNodeValue()); assertEquals("http://chiba.sourceforge.net/2003/08/xforms", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "chiba").getNodeValue()); assertEquals("http://www.w3.org/2001/xml-events", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "ev").getNodeValue()); assertEquals("http://my", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "my").getNodeValue()); assertEquals("http://www.w3.org/2002/xforms", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "xforms").getNodeValue()); assertEquals("http://www.w3.org/2001/XMLSchema", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "xsd").getNodeValue()); assertEquals("http://www.w3.org/2001/XMLSchema-instance", attributes.getNamedItemNS(NamespaceCtx.XMLNS_NS, "xsi").getNodeValue()); }
From source file:org.chiba.xml.xpath.impl.JXPathDOMFactoryTest.java
private void assertNamespaceDeclarations(Node node) { assertNotNull(node);//from w w w . j a v a 2 s . c om assertEquals(Node.ELEMENT_NODE, node.getNodeType()); NamedNodeMap attributes = node.getAttributes(); int nsDeclarations = 0; for (int i = 0; i < attributes.getLength(); i++) { Node attr = attributes.item(i); if (NamespaceConstants.XMLNS_NS.equals(attr.getNamespaceURI())) { nsDeclarations++; } } assertEquals(7, nsDeclarations); assertEquals("", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "xmlns").getNodeValue()); assertEquals("http://chiba.sourceforge.net/xforms", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "chiba").getNodeValue()); assertEquals("http://www.w3.org/2001/xml-events", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "ev").getNodeValue()); assertEquals("http://my", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "my").getNodeValue()); assertEquals("http://www.w3.org/2002/xforms", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "xf").getNodeValue()); assertEquals("http://www.w3.org/2001/XMLSchema", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "xsd").getNodeValue()); assertEquals("http://www.w3.org/2001/XMLSchema-instance", attributes.getNamedItemNS(NamespaceConstants.XMLNS_NS, "xsi").getNodeValue()); }