public String translateNamespacePrefixToUri(String prefix) { // Empty prefix always maps to empty URL in XPath if (prefix.length() == 0) { return prefix; } synchronized (namespaces) { Namespace ns = (Namespace) namespaces.get(prefix); return ns == null ? null : ns.getURI(); } } }
public List operate(Object node) { if (node instanceof Element) return Collections.singletonList(((Element) node).getNamespace().getURI()); else if (node instanceof Attribute) return Collections.singletonList(((Attribute) node).getNamespace().getURI()); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_nsuri can not be applied on " + node.getClass()); } }
public String toString() { return ( "[xmlns:" + jdomNamespace.getPrefix() + "=\"" + jdomNamespace.getURI() + "\", element=" + jdomElement.getName() + "]" ); } }
public List operate(Object node) { if (node instanceof Element) { Element element = (Element) node; return Collections.singletonList(element.getNamespace().getURI() + element.getName()); } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; return Collections.singletonList(attribute.getNamespace().getURI() + attribute.getName()); } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_cname can not be applied on " + node.getClass()); } }
public List operate(Object node, String localName, Namespace namespace) { if (node instanceof Element) { return((Element) node).getChildren(localName, namespace); } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (root != null && root.getName().equals(localName) && root.getNamespaceURI().equals(namespace.getURI())) { return Collections.singletonList(root); } else return Collections.EMPTY_LIST; } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; /* else throw new TemplateModelException("_namedChildren can not be applied on " + node.getClass()); */ } }
return namespace.getURI();
/** * Returns the namespace URI this parser handles. * <p> * * @return the namespace URI. */ public String getNamespaceUri() { return ModuleParser.TEMP.getURI(); }
/** * Returns the URI of the module. * <p> * * @return URI of the module. */ public String getUri() { return ModuleParser.TEMP.getURI(); }
/** * Returns the namespace URI mapped to this element's prefix (or the * in-scope default namespace URI if no prefix). If no mapping is found, an * empty string is returned. * * @return the namespace URI for this element */ public String getNamespaceURI() { return namespace.getURI(); }
public String getNamespaceURI(String prefix) { Namespace namespace = element.getNamespace(prefix); if (namespace == null) { return null; } return namespace.getURI(); }
/** * This will add a new <code>{@link Namespace}</code> * to those currently available. * * @param ns <code>Namespace</code> to add. */ public void push(Namespace ns) { prefixes.push(ns.getPrefix()); uris.push(ns.getURI()); }
private void writeObject(final ObjectOutputStream out) throws IOException { out.defaultWriteObject(); // We use writeObject() and not writeUTF() to minimize space // This allows for writing pointers to already written strings out.writeObject(namespace.getPrefix()); out.writeObject(namespace.getURI()); }
private String getDeclaredURI(String string) { for (int i = namespaceStack.size() - 1; i == 0; i--) { Map<String, Namespace> nmspaces = namespaceStack.get(i); Namespace dec = nmspaces.get(string); if (dec != null) { return dec.getURI(); } } return null; }
private String getPrefixValue(String prefix, Element service) { if (service != null && service.getNamespace(prefix) != null) { return service.getNamespace(prefix).getURI(); } return null; }
public List operate(Object node) { if (node instanceof Element) return Collections12.singletonList(((Element)node).getNamespace().getURI()); else if (node instanceof Attribute) return Collections12.singletonList(((Attribute)node).getNamespace().getURI()); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_nsuri can not be applied on " + node.getClass()); } }
/** * * @return * @throws MobyException */ public static Document createDomDocument() throws MobyException { Document d = new Document(); d.setBaseURI(MOBY_NS.getURI()); return d; }
public void writeNamespace(String prefix, String namespace) throws XMLStreamException { Namespace decNS = currentNode.getNamespace(prefix); if (decNS == null || !decNS.getURI().equals(namespace)) { currentNode.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespace)); } }
private boolean shouldDeclare(Namespace ns) { if (ns == Namespace.XML_NAMESPACE) { return false; } if (ns == Namespace.NO_NAMESPACE && getDeclaredURI("") == null) { return false; } String decUri = getDeclaredURI(ns.getPrefix()); return !(decUri != null && decUri.equals(ns.getURI())); }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null) { eItem.addContent(generateSimpleElement("description",description.getValue())); } if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } }