private StructuredQName resolveQName(String val, NodeInfo element) throws XPathException { if (val.startsWith("Q{")) { return StructuredQName.fromEQName(val); } else if (val.contains(":")) { NamespaceResolver resolver = new InscopeNamespaceResolver(element); return StructuredQName.fromLexicalQName(val, true, true, resolver); } else { return new StructuredQName("", "", val); } }
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode); boolean all = false; all = true; } else if ("#default".equals(pfx)) { found = (inscopeNS.getURIForPrefix("", true) != null); if (found) { excludeURIs.add(inscopeNS.getURIForPrefix("", true)); found = (inscopeNS.getURIForPrefix(pfx, false) != null); if (found) { excludeURIs.add(inscopeNS.getURIForPrefix(pfx, false)); Iterator<?> pfxiter = inscopeNS.iteratePrefixes(); while (pfxiter.hasNext()) { String pfx = (String)pfxiter.next(); boolean def = ("".equals(pfx)); excludeURIs.add(inscopeNS.getURIForPrefix(pfx,def));
public boolean hasDefaultNamespace() { if (!hasDefaultNamespace.isPresent()) { hasDefaultNamespace = Optional.of( !new InscopeNamespaceResolver(getParent()).getURIForPrefix("", true).isEmpty()); } return hasDefaultNamespace.get(); }
private StructuredQName resolveQName(String val, NodeInfo element) throws XPathException { if (val.startsWith("Q{")) { return StructuredQName.fromEQName(val); } else if (val.contains(":")) { NamespaceResolver resolver = new InscopeNamespaceResolver(element); return StructuredQName.fromLexicalQName(val, true, true, resolver); } else { return new StructuredQName("", "", val); } }
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode); boolean all = false; all = true; } else if ("#default".equals(pfx)) { found = (inscopeNS.getURIForPrefix("", true) != null); if (found) { excludeURIs.add(inscopeNS.getURIForPrefix("", true)); found = (inscopeNS.getURIForPrefix(pfx, false) != null); if (found) { excludeURIs.add(inscopeNS.getURIForPrefix(pfx, false)); Iterator<?> pfxiter = inscopeNS.iteratePrefixes(); while (pfxiter.hasNext()) { String pfx = (String)pfxiter.next(); boolean def = ("".equals(pfx)); excludeURIs.add(inscopeNS.getURIForPrefix(pfx,def));
/** * Static method to resolve a lexical QName against the namespace context of a supplied element node * * @param lexicalQName the lexical QName * @param element the element node whose namespace context is to be used * @return the result of resolving the QName * @throws XPathException if the supplied value is not a valid lexical QName, or if its namespace * prefix is not in scope */ /*@Nullable*/ public static QNameValue resolveQName(CharSequence lexicalQName, NodeInfo element) throws XPathException { NamespaceResolver resolver = new InscopeNamespaceResolver(element); StructuredQName qName = StructuredQName.fromLexicalQName(lexicalQName, true, false, resolver); return new QNameValue(qName, BuiltInAtomicType.QNAME); }
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode); Iterator<?> prefixes = inscopeNS.iteratePrefixes(); while (prefixes.hasNext()) { String nspfx = (String)prefixes.next(); String nsuri = inscopeNS.getURIForPrefix(nspfx, true); nsbindings.put(nspfx,nsuri);
/** * Static method to resolve a lexical QName against the namespace context of a supplied element node * * @param lexicalQName the lexical QName * @param element the element node whose namespace context is to be used * @return the result of resolving the QName * @throws XPathException if the supplied value is not a valid lexical QName, or if its namespace * prefix is not in scope */ /*@Nullable*/ public static QNameValue resolveQName(CharSequence lexicalQName, NodeInfo element) throws XPathException { NamespaceResolver resolver = new InscopeNamespaceResolver(element); StructuredQName qName = StructuredQName.fromLexicalQName(lexicalQName, true, false, resolver); return new QNameValue(qName, BuiltInAtomicType.QNAME); }
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode); Iterator<?> prefixes = inscopeNS.iteratePrefixes(); while (prefixes.hasNext()) { String nspfx = (String)prefixes.next(); String nsuri = inscopeNS.getURIForPrefix(nspfx, true); nsbindings.put(nspfx,nsuri);
/** * Construct a QName from a lexical QName, supplying an element node whose * in-scope namespaces are to be used to resolve any prefix contained in the QName. * <p>This constructor checks that the components of the QName are * lexically valid.</p> * <p>If the lexical QName has no prefix, the name is considered to be in the * default namespace, as defined by <code>xmlns="..."</code>.</p> * <p>If the prefix of the lexical QName is not in scope, returns null.</p> * * @param lexicalQName The lexical QName, in the form <code>prefix:local</code> * or simply <code>local</code>. The EQName syntax "Q{uri}local" * and the ClarkName syntax "{uri}local" are also accepted. * @param element The element node whose in-scope namespaces are to be used * to resolve the prefix part of the lexical QName. * @throws IllegalArgumentException If the prefix of the lexical QName is not in scope * or if the lexical QName is invalid (for example, if it contains invalid characters) */ public QName(String lexicalQName, XdmNode element) { if (lexicalQName.startsWith("{")) { lexicalQName = "Q" + lexicalQName; } try { NodeInfo node = (NodeInfo) element.getUnderlyingValue(); sqName = StructuredQName.fromLexicalQName(lexicalQName, true, true, new InscopeNamespaceResolver(node)); } catch (XPathException err) { throw new IllegalArgumentException(err); } }
NodeInfo inode = nsbinding.getNode().getUnderlyingNode(); NamePool pool = inode.getConfiguration().getNamePool(); InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode); Iterator<?> pfxiter = inscopeNS.iteratePrefixes(); while (pfxiter.hasNext()) { String nspfx = (String)pfxiter.next(); String nsuri = inscopeNS.getURIForPrefix(nspfx, "".equals(nspfx)); lclnsBindings.put(nspfx, nsuri);
/** * Construct a QName from a lexical QName, supplying an element node whose * in-scope namespaces are to be used to resolve any prefix contained in the QName. * <p>This constructor checks that the components of the QName are * lexically valid.</p> * <p>If the lexical QName has no prefix, the name is considered to be in the * default namespace, as defined by <code>xmlns="..."</code>.</p> * <p>If the prefix of the lexical QName is not in scope, returns null.</p> * * @param lexicalQName The lexical QName, in the form <code>prefix:local</code> * or simply <code>local</code>. The EQName syntax "Q{uri}local" * and the ClarkName syntax "{uri}local" are also accepted. * @param element The element node whose in-scope namespaces are to be used * to resolve the prefix part of the lexical QName. * @throws IllegalArgumentException If the prefix of the lexical QName is not in scope * or if the lexical QName is invalid (for example, if it contains invalid characters) */ public QName(String lexicalQName, XdmNode element) { if (lexicalQName.startsWith("{")) { lexicalQName = "Q" + lexicalQName; } try { NodeInfo node = (NodeInfo) element.getUnderlyingValue(); sqName = StructuredQName.fromLexicalQName(lexicalQName, true, true, new InscopeNamespaceResolver(node)); } catch (XPathException err) { throw new IllegalArgumentException(err); } }
NodeInfo inode = nsbinding.getNode().getUnderlyingNode(); NamePool pool = inode.getConfiguration().getNamePool(); InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode); Iterator<?> pfxiter = inscopeNS.iteratePrefixes(); while (pfxiter.hasNext()) { String nspfx = (String)pfxiter.next(); String nsuri = inscopeNS.getURIForPrefix(nspfx, "".equals(nspfx)); lclnsBindings.put(nspfx, nsuri);
/** * Private supporting method * * @param p the prefix * @param element the element node * @return the corresponding namespace, or null if not in scope */ /*@Nullable*/ private static AnyURIValue namespaceUriForPrefix(StringValue p, NodeInfo element) { String prefix; if (p == null) { prefix = ""; } else { prefix = p.getStringValue(); } NamespaceResolver resolver = new InscopeNamespaceResolver(element); String uri = resolver.getURIForPrefix(prefix, true); if (uri == null || uri.isEmpty()) { return null; } return new AnyURIValue(uri); }
/** * Private supporting method * * @param p the prefix * @param element the element node * @return the corresponding namespace, or null if not in scope */ /*@Nullable*/ private static AnyURIValue namespaceUriForPrefix(StringValue p, NodeInfo element) { String prefix; if (p == null) { prefix = ""; } else { prefix = p.getStringValue(); } NamespaceResolver resolver = new InscopeNamespaceResolver(element); String uri = resolver.getURIForPrefix(prefix, true); if (uri == null || uri.isEmpty()) { return null; } return new AnyURIValue(uri); }
private IndependentContext makeStaticContext(NodeInfo element) { StylesheetPackage pack = packStack.peek(); IndependentContext env = new IndependentContext(config); final InscopeNamespaceResolver resolver = new InscopeNamespaceResolver(element); env.setNamespaceResolver(resolver); env.setImportedSchemaNamespaces(pack.getSchemaNamespaces()); env.getImportedSchemaNamespaces().add(NamespaceConstant.ANONYMOUS); parser.getQNameParser().setNamespaceResolver(resolver); return env; }
private IndependentContext makeStaticContext(NodeInfo element) { StylesheetPackage pack = packStack.peek(); IndependentContext env = new IndependentContext(config); final InscopeNamespaceResolver resolver = new InscopeNamespaceResolver(element); env.setNamespaceResolver(resolver); env.setImportedSchemaNamespaces(pack.getSchemaNamespaces()); env.getImportedSchemaNamespaces().add(NamespaceConstant.ANONYMOUS); parser.getQNameParser().setNamespaceResolver(resolver); return env; }
/** * Construct a QName from a lexical QName, supplying an element node whose * in-scope namespaces are to be used to resolve any prefix contained in the QName. * * <p>This constructor checks that the components of the QName are * lexically valid.</p> * <p>If the lexical QName has no prefix, the name is considered to be in the * default namespace, as defined by <code>xmlns="..."</code>.</p> * <p>If the prefix of the lexical QName is not in scope, returns null.</p> * * @param lexicalQName The lexical QName, in the form <code>prefix:local</code> * or simply <code>local</code>. * @param element The element node whose in-scope namespaces are to be used * to resolve the prefix part of the lexical QName. * @throws IllegalArgumentException If the prefix of the lexical QName is not in scope * or if the lexical QName is invalid (for example, if it contains invalid characters) */ public QName(String lexicalQName, XdmNode element) { try { NodeInfo node = (NodeInfo) element.getUnderlyingValue(); sqName = StructuredQName.fromLexicalQName(lexicalQName, true, node.getConfiguration().getNameChecker(), new InscopeNamespaceResolver(node)); } catch (XPathException err) { throw new IllegalArgumentException(err); } }
NamespaceResolver inscope = new InscopeNamespaceResolver(getRawParent());
NamespaceResolver inscope = new InscopeNamespaceResolver(getRawParent());