@Test public void testGetDeclaredNamespaces() { try { rootNode.getDeclaredNamespaces( new NamespaceBinding[] {new NamespaceBinding("prefix", "uri")}); fail("Exception is excepted"); } catch (UnsupportedOperationException ex) { assertEquals( "Invalid exception message", "Operation is not supported", ex.getMessage()); } }
/** * Notify a namespace prefix to URI binding */ public void startPrefixMapping(String prefix, String uri) { //System.err.println("StartPrefixMapping " + prefix + "=" + uri); if (prefix.equals("xmlns")) { // the binding xmlns:xmlns="http://www.w3.org/2000/xmlns/" // should never be reported, but it's been known to happen return; } if (namespacesUsed >= namespaces.length) { namespaces = Arrays.copyOf(namespaces, namespacesUsed * 2); } namespaces[namespacesUsed++] = new NamespaceBinding(prefix, uri); }
/** * Notify a namespace prefix to URI binding */ public void startPrefixMapping(String prefix, String uri) { //System.err.println("StartPrefixMapping " + prefix + "=" + uri); if (prefix.equals("xmlns")) { // the binding xmlns:xmlns="http://www.w3.org/2000/xmlns/" // should never be reported, but it's been known to happen return; } if (namespacesUsed >= namespaces.length) { namespaces = Arrays.copyOf(namespaces, namespacesUsed * 2); } namespaces[namespacesUsed++] = new NamespaceBinding(prefix, uri); }
/** * Get a {@link net.sf.saxon.om.NamespaceBinding} whose (prefix, uri) pair are the prefix and URI of this * node name * * @return the corresponding NamespaceBinding */ public NamespaceBinding getNamespaceBinding() { return new NamespaceBinding(prefix, pool.getURI(fingerprint)); }
/** * Get a {@link net.sf.saxon.om.NamespaceBinding} whose (prefix, uri) pair are the prefix and URI of this * node name * * @return the corresponding NamespaceBinding */ public NamespaceBinding getNamespaceBinding() { return new NamespaceBinding(prefix, pool.getURI(fingerprint)); }
/** * Create a binding of a prefix to a URI. Static factory method for the convenience of compiled bytecode; * reuses standard NamespaceBinding objects where possible * * @param prefix the prefix: either an NCName, or a zero-length string to bind the default namespace. * Must not be null. * @param uri the namespace URI: either a URI, or a zero-length string to unbind the prefix. Must * not be null. * @return the namespace binding object */ public static NamespaceBinding makeNamespaceBinding(CharSequence prefix, CharSequence uri) { if (prefix.length()==0 && uri.length()==0) { return DEFAULT_UNDECLARATION; } else if (prefix.equals("xml") && uri.equals(NamespaceConstant.XML)) { return XML; } else { return new NamespaceBinding(prefix.toString(), uri.toString()); } }
/** * Create a binding of a prefix to a URI. Static factory method for the convenience of compiled bytecode; * reuses standard NamespaceBinding objects where possible * * @param prefix the prefix: either an NCName, or a zero-length string to bind the default namespace. * Must not be null. * @param uri the namespace URI: either a URI, or a zero-length string to unbind the prefix. Must * not be null. * @return the namespace binding object */ public static NamespaceBinding makeNamespaceBinding(CharSequence prefix, CharSequence uri) { if (prefix.length()==0 && uri.length()==0) { return DEFAULT_UNDECLARATION; } else if (prefix.equals("xml") && uri.equals(NamespaceConstant.XML)) { return XML; } else { return new NamespaceBinding(prefix.toString(), uri.toString()); } }
public void setPrefix(String prefix, String uri) { // See Saxon bug 2398: this should have stack-like effect checkNonNull(prefix); if (uri == null) { uri = ""; } if (isInvalidURI(uri)) { throw new IllegalArgumentException("Invalid namespace URI: " + uri); } if (!"".equals(prefix) && !isValidNCName(prefix)) { throw new IllegalArgumentException("Invalid namespace prefix: " + prefix); } setPrefixes.peek().add(new NamespaceBinding(prefix, uri)); }
public void setPrefix(String prefix, String uri) { // See Saxon bug 2398: this should have stack-like effect checkNonNull(prefix); if (uri == null) { uri = ""; } if (isInvalidURI(uri)) { throw new IllegalArgumentException("Invalid namespace URI: " + uri); } if (!"".equals(prefix) && !isValidNCName(prefix)) { throw new IllegalArgumentException("Invalid namespace prefix: " + prefix); } setPrefixes.peek().add(new NamespaceBinding(prefix, uri)); }
public void addNamespace(String prefix, String uri) { NamespaceBinding nsbind = new NamespaceBinding(prefix, uri); try { receiver.namespace(nsbind, 0); } catch (XPathException e) { throw new XProcException(e); } }
public void addNamespace(String prefix, String uri) { NamespaceBinding nsbind = new NamespaceBinding(prefix, uri); try { receiver.namespace(nsbind, 0); } catch (XPathException e) { throw new XProcException(e); } }
/** * Output a namespace declaration * * @param prefix the namespace prefix * @param uri the namespace URI */ public void namespace(String prefix, String uri) { try { receiver.namespace(new NamespaceBinding(prefix, uri), 0); } catch (XPathException e) { e.printStackTrace(); throw new InternalError(e.getMessage()); } }
/** * Output a namespace declaration * * @param prefix the namespace prefix * @param uri the namespace URI */ public void namespace(String prefix, String uri) { try { receiver.namespace(new NamespaceBinding(prefix, uri), 0); } catch (XPathException e) { e.printStackTrace(); throw new InternalError(e.getMessage()); } }
public void processValue(CharSequence value, XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); String uri = value.toString(); checkPrefixAndUri(prefix, uri, context); NamespaceBinding nscode = new NamespaceBinding(prefix, uri); Receiver out = context.getReceiver(); out.namespace(nscode, ReceiverOptions.REJECT_DUPLICATES); }
public void processValue(CharSequence value, XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); String uri = value.toString(); checkPrefixAndUri(prefix, uri, context); NamespaceBinding nscode = new NamespaceBinding(prefix, uri); Receiver out = context.getReceiver(); out.namespace(nscode, ReceiverOptions.REJECT_DUPLICATES); }
/** * Rename this node * * @param newName the new name */ public void rename(NodeName newName) { String prefix = newName.getPrefix(); String uri = newName.getURI(); NamespaceBinding ns = new NamespaceBinding(prefix, uri); String uc = getURIForPrefix(prefix, true); if (uc == null) { uc = ""; } if (!uc.equals(uri)) { if (uc.isEmpty()) { addNamespace(ns, false); } else { throw new IllegalArgumentException( "Namespace binding of new name conflicts with existing namespace binding"); } } nodeName = newName; }
/** * startContent: Add any namespace undeclarations needed to stop * namespaces being inherited from parent elements */ public void startContent() throws XPathException { if (pendingUndeclarations != null) { for (NamespaceBinding ns : pendingUndeclarations) { if (ns != null) { namespace(new NamespaceBinding(ns.getPrefix(), ""), 0); // relies on the namespace() method to prevent duplicate undeclarations } } } pendingUndeclarations = null; nextReceiver.startContent(); }
/** * startContent: Add any namespace undeclarations needed to stop * namespaces being inherited from parent elements */ public void startContent() throws XPathException { if (pendingUndeclarations != null) { for (NamespaceBinding ns : pendingUndeclarations) { if (ns != null) { namespace(new NamespaceBinding(ns.getPrefix(), ""), 0); // relies on the namespace() method to prevent duplicate undeclarations } } } pendingUndeclarations = null; nextReceiver.startContent(); }
/** * Notify the start of an element * * Specific treatment of elements in XHTML, SVG and MathML namespaces forces a namespace to be emitted too, * rather than by higher level default behaviour. * @param elemName integer code identifying the name of the element within the name pool. * @param typeCode integer code identifying the element's type within the name pool. * @param location * @param properties properties of the element node */ @Override public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException { if (isSpecial(elemName.getURI())) { if (!elemName.getPrefix().isEmpty()) { elemName = new FingerprintedQName("", elemName.getURI(), elemName.getLocalPart()); } super.startElement(elemName, typeCode, location, properties); super.namespace(new NamespaceBinding("", elemName.getURI()), properties); } else { super.startElement(elemName, typeCode, location, properties); } }
public void open() throws XPathException { //@SuppressWarnings({"FieldCanBeLocal"}) FingerprintedQName resultSequence = new FingerprintedQName("result", RESULT_NS, "sequence"); resultDocument = new FingerprintedQName("result", RESULT_NS, "document"); resultElement = new FingerprintedQName("result", RESULT_NS, "element"); resultAttribute = new FingerprintedQName("result", RESULT_NS, "attribute"); resultText = new FingerprintedQName("result", RESULT_NS, "text"); resultComment = new FingerprintedQName("result", RESULT_NS, "comment"); resultPI = new FingerprintedQName("result", RESULT_NS, "processing-instruction"); resultNamespace = new FingerprintedQName("result", RESULT_NS, "namespace"); resultAtomicValue = new FingerprintedQName("result", RESULT_NS, "atomic-value"); resultFunction = new FingerprintedQName("result", RESULT_NS, "function"); resultArray = new FingerprintedQName("result", RESULT_NS, "array"); resultMap = new FingerprintedQName("result", RESULT_NS, "map"); resultExternalValue = new FingerprintedQName("result", RESULT_NS, "external-object"); xsiType = new FingerprintedQName("xsi", NamespaceConstant.SCHEMA_INSTANCE, "type"); out.open(); out.startDocument(0); out.startElement(resultSequence, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0); out.namespace(new NamespaceBinding("result", RESULT_NS), 0); out.namespace(new NamespaceBinding("xs", NamespaceConstant.SCHEMA), 0); out.namespace(new NamespaceBinding("xsi", NamespaceConstant.SCHEMA_INSTANCE), 0); out.startContent(); }