public String getNamespacePrefix(Object o) { if (isElement(o)) { return ((Element)o).getNamespacePrefix(); } else if (isAttribute(o)) { return ((Attribute)o).getNamespacePrefix(); } else if (o instanceof XPathNamespace) { return ((XPathNamespace)o).getNamespacePrefix(); } return null; }
public Iterator getNamespaceAxisIterator(Object o) { if (! isElement(o)) { return JaxenConstants.EMPTY_ITERATOR; } Map nsMap = new HashMap(); Element elt = (Element)o; ParentNode parent = elt; while (parent instanceof Element) { elt = (Element)parent; String uri = elt.getNamespaceURI(); String prefix = elt.getNamespacePrefix(); addNamespaceForElement(elt, uri, prefix, nsMap); int count = elt.getNamespaceDeclarationCount(); for (int i = 0; i < count; i++) { prefix = elt.getNamespacePrefix(i); uri = elt.getNamespaceURI(prefix); addNamespaceForElement(elt, uri, prefix, nsMap); } parent = elt.getParent(); } addNamespaceForElement(elt, "http://www.w3.org/XML/1998/namespace", "xml", nsMap); return nsMap.values().iterator(); } }
/** * Get the prefix of the name of the node. This is defined only for elements and attributes. * If the node has no prefix, or for other kinds of node, return a zero-length string. * * @return The prefix of the name of the node. */ public String getPrefix() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getNamespacePrefix(); case Type.ATTRIBUTE: return ((Attribute) node).getNamespacePrefix(); default: return ""; } }
/** * Get the prefix of the name of the node. This is defined only for elements and attributes. * If the node has no prefix, or for other kinds of node, return a zero-length string. * * @return The prefix of the name of the node. */ public String getPrefix() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getNamespacePrefix(); case Type.ATTRIBUTE: return ((Attribute) node).getNamespacePrefix(); default: return ""; } }
/** * Get the prefix of the name of the node. This is defined only for elements and attributes. * If the node has no prefix, or for other kinds of node, return a zero-length string. * * @return The prefix of the name of the node. */ public String getPrefix() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getNamespacePrefix(); case Type.ATTRIBUTE: return ((Attribute) node).getNamespacePrefix(); default: return ""; } }
/** * @param node * @param count */ private static List<String> getNamespaceURIList(Element node) { List<String> namespaceURIList = new ArrayList<String>(); for (int i = 0; i < node.getNamespaceDeclarationCount(); i++) { String prefix = node.getNamespacePrefix(i); String refNamespaceURI = node.getNamespaceURI(prefix); namespaceURIList.add(refNamespaceURI); } return namespaceURIList; }
/** * If the prefix for the Concordion namespace is something other than "concordion", eg "c", this * updates the stylesheet to use the prefix. * This is required since <a href="http://stackoverflow.com/questions/24628932/do-css-namespace-attribute-selectors-work-with-xhtml-html-elements"> * namespaced CSS selectors generally don't work with HTML</a>, so <code>embedded.css</code> uses hardcoded namespace prefixes (eg. <code>[concordion\:example]</code>). */ private String updateConcordionNamespacePrefix(Element html, String stylesheetContent) { for (int i=0; i<html.getNamespaceDeclarationCount(); i++) { String prefix = html.getNamespacePrefix(i); if (ConcordionBuilder.NAMESPACE_CONCORDION_2007.equals(html.getNamespaceURI(prefix))) { return stylesheetContent.replace("concordion\\:", prefix + "\\:"); } } return stylesheetContent; } }
/** * If the prefix for the Concordion namespace is something other than "concordion", eg "c", this * updates the stylesheet to use the prefix. * This is required since <a href="http://stackoverflow.com/questions/24628932/do-css-namespace-attribute-selectors-work-with-xhtml-html-elements"> * namespaced CSS selectors generally don't work with HTML</a>, so <code>embedded.css</code> uses hardcoded namespace prefixes (eg. <code>[concordion\:example]</code>). */ private String updateConcordionNamespacePrefix(Element html, String stylesheetContent) { for (int i=0; i<html.getNamespaceDeclarationCount(); i++) { String prefix = html.getNamespacePrefix(i); if (ConcordionBuilder.NAMESPACE_CONCORDION_2007.equals(html.getNamespaceURI(prefix))) { return stylesheetContent.replace("concordion\\:", prefix + "\\:"); } } return stylesheetContent; } }
public XmlName(Element element) { this.prefix = element.getNamespacePrefix(); this.localName = element.getLocalName(); this.namespace = element.getNamespaceURI(); }
public XmlName(Element element) { this.prefix = element.getNamespacePrefix(); this.localName = element.getLocalName(); this.namespace = element.getNamespaceURI(); }
public XmlName(Element element) { this.prefix = element.getNamespacePrefix(); this.localName = element.getLocalName(); this.namespace = element.getNamespaceURI(); }
private static Map getNamespacePrefixesInScopeNonPublic(Element element) { HashMap namespaces = new HashMap(); do { int size = element.getNamespaceDeclarationCount(); for (int i = 0; i < size; i++) { String prefix = element.getNamespacePrefix(i); if (!namespaces.containsKey(prefix)) { String uri = element.getNamespaceURI(prefix); namespaces.put(prefix, uri); } } ParentNode parent = element.getParent(); element = (parent instanceof Element ? (Element) parent : null); } while (element != null); return namespaces; }
private static Map getNamespacePrefixesInScopeNonPublic(Element element) { HashMap namespaces = new HashMap(); do { int size = element.getNamespaceDeclarationCount(); for (int i = 0; i < size; i++) { String prefix = element.getNamespacePrefix(i); if (!namespaces.containsKey(prefix)) { String uri = element.getNamespaceURI(prefix); namespaces.put(prefix, uri); } } ParentNode parent = element.getParent(); element = (parent instanceof Element ? (Element) parent : null); } while (element != null); return namespaces; }
private void writeNamespaceDeclarations(Element elem) { int count = elem.getNamespaceDeclarationCount(); if (count == 1) return; // elem.getNamespaceURI() has already been written for (int i = 0; i < count; i++) { String prefix = elem.getNamespacePrefix(i); String uri = elem.getNamespaceURI(prefix); if (prefix.equals(elem.getNamespacePrefix()) && uri.equals(elem.getNamespaceURI())) { // if (DEBUG) System.err.println("********** NAMESPACE IGNORED ON WRITE ***************\n"); continue; } nodeTokens.add((byte)NAMESPACE_DECLARATION); writeIndex(prefix); writeIndex(uri); } }
private void writeNamespaceDeclarations(Element elem) { int count = elem.getNamespaceDeclarationCount(); if (count == 1) return; // elem.getNamespaceURI() has already been written for (int i = 0; i < count; i++) { String prefix = elem.getNamespacePrefix(i); String uri = elem.getNamespaceURI(prefix); if (prefix.equals(elem.getNamespacePrefix()) && uri.equals(elem.getNamespaceURI())) { // if (DEBUG) System.err.println("********** NAMESPACE IGNORED ON WRITE ***************\n"); continue; } nodeTokens.add((byte)NAMESPACE_DECLARATION); writeIndex(prefix); writeIndex(uri); } }
public DefaultField(Element elm) { this.name = elm.getLocalName(); this.namespace = elm.getNamespaceURI(); this.prefix = elm.getNamespacePrefix(); for(int i = 0; i<elm.getAttributeCount(); i++) { Attribute attribute = elm.getAttribute(i); fields.add(new DefaultField(attribute.getNamespaceURI(), attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getValue())); } this.content = XmlUtil.innerToString(elm); }
final void writeStartTag(Element elem) { writeIndex(elem.getNamespacePrefix(), elem.getLocalName()); int type = BEGIN_ELEMENT; if (elem.getNamespaceURI().length() == 0) { type = Util.noNamespace(type); } else { writeIndex(elem.getNamespaceURI()); } nodeTokens.add((byte)type); for (int i = 0; i < elem.getAttributeCount(); i++) { writeAttribute(elem.getAttribute(i)); } writeNamespaceDeclarations(elem); }
final void writeStartTag(Element elem) { writeIndex(elem.getNamespacePrefix(), elem.getLocalName()); int type = BEGIN_ELEMENT; if (elem.getNamespaceURI().length() == 0) { type = Util.noNamespace(type); } else { writeIndex(elem.getNamespaceURI()); } nodeTokens.add((byte)type); for (int i = 0; i < elem.getAttributeCount(); i++) { writeAttribute(elem.getAttribute(i)); } writeNamespaceDeclarations(elem); }
protected SwordValidationInfo handleIncorrectElement(Element element, Properties validationProperties) throws UnmarshallException { log.error( "Unexpected element. Expected: " + getQualifiedName() + ". Got: " + ((element != null) ? element.getQualifiedName() : "null")); if (validationProperties != null) { SwordValidationInfo info = new SwordValidationInfo( new XmlName(element.getNamespacePrefix(), element.getLocalName(), element.getNamespaceURI()), "This is not the expected element. Received: " + element.getQualifiedName() + " for namespaceUri: " + element.getNamespaceURI(), SwordValidationInfoType.ERROR ); return info; } else { throw new UnmarshallException("Not a " + getQualifiedName() + " element"); } }
protected SwordValidationInfo handleIncorrectElement(Element element, Properties validationProperties) throws UnmarshallException { log.error("Unexpected element. Expected: " + getQualifiedName() + ". Got: " + ((element != null) ? element.getQualifiedName() : "null" )); if( validationProperties != null ) { SwordValidationInfo info = new SwordValidationInfo( new XmlName(element.getNamespacePrefix(), element.getLocalName(), element.getNamespaceURI()), "This is not the expected element. Received: " + element.getQualifiedName() + " for namespaceUri: " + element.getNamespaceURI(), SwordValidationInfoType.ERROR ); return info; } else { throw new UnmarshallException( "Not a " + getQualifiedName() + " element" ); } }