/** * Validate a QName, and return the prefix and local name. Both parts are checked * to ensure they are valid NCNames. * <p/> * <p><i>Used from compiled code</i></p> * * @param qname the lexical QName whose parts are required. Note that leading and trailing * whitespace is not permitted * @return an array of two strings, the prefix and the local name. The first * item is a zero-length string if there is no prefix. * @throws XPathException if not a valid QName. */ public final String[] checkQNameParts(CharSequence qname) throws XPathException { try { String[] parts = getQNameParts(qname); if (parts[0].length() > 0 && !isValidNCName(parts[0])) { throw new XPathException("Invalid QName prefix " + Err.wrap(parts[0])); } return parts; } catch (QNameException e) { throw new XPathException(e); } }
String prefix = NameChecker.getPrefix(rawname); int nc = pool.allocate(prefix, uri, localname); n = new Integer(nc);
/** * Validate whether a given string constitutes a valid NCName, as defined in XML Namespaces. * * @param ncName the name to be tested * @return true if the name is a lexically-valid QName */ public final boolean isValidNCName(CharSequence ncName) { if (ncName.length() == 0) { return false; } char ch = ncName.charAt(0); if (!isNCNameStartChar(ch)) { return false; } for (int i = 1; i < ncName.length(); i++) { ch = ncName.charAt(i); if (!isNCNameChar(ch)) { return false; } } return true; }
/** * Test whether a supplied name is a valid NCName * * @param name the name to be tested * @return true if the name is valid or if checking is disabled */ private boolean isValidNCName(String name) { return !isChecking || NameChecker.isValidNCName(name); }
public static String[] validateQName(String name) throws TeiidProcessingException { try { return NameChecker.getQNameParts(name); } catch (QNameException e) { throw new TeiidProcessingException(e); } }
} while (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '='); String attName = buff.toString(); if (!NameChecker.isQName(attName)) { grumble("Invalid attribute name " + Err.wrap(attName, Err.ATTRIBUTE)); String[] parts = NameChecker.getQNameParts(elname); String namespace = ((QueryModule) env).checkURIForPrefix(parts[0]); if (namespace == null) { String attNamespace; try { String[] parts = NameChecker.getQNameParts(attName); if (parts[0].isEmpty()) {
AtomicValue val = (AtomicValue)((Literal)elementName).getValue(); if (val instanceof StringValue) { String[] parts = visitor.getConfiguration().getNameChecker().checkQNameParts(val.getStringValueCS()); if (namespace == null) { String prefix = parts[0];
if (!checker.isValidNCName(buff)) { ValidationFailure err = new ValidationFailure("The value '" + val + "' is not a valid Name"); err.setErrorCode("FORG0001"); case StandardNames.XS_IDREF: case StandardNames.XS_ENTITY: if (!checker.isValidNCName(val)) { ValidationFailure err = new ValidationFailure("The value '" + val + "' is not a valid NCName"); err.setErrorCode("FORG0001"); if (!checker.isValidNmtoken(val)) { ValidationFailure err = new ValidationFailure("The value '" + val + "' is not a valid NMTOKEN"); err.setErrorCode("FORG0001");
/** * Check to see if a string is a valid Nmtoken according to [7] * in the XML 1.0 Recommendation * * @param nmtoken string to check * @return true if nmtoken is a valid Nmtoken */ public final boolean isValidNmtoken(CharSequence nmtoken) { if (nmtoken.length() == 0) { return false; } for (int i = 0; i < nmtoken.length(); i++) { char ch = nmtoken.charAt(i); if (ch != ':' && !isNCNameChar(ch)) { return false; } } return true; }
/** * Test whether a given integer is the codepoint of a valid XML character * * @param c the XPath dynamic context * @param in the character to be tested * @return true if and only if the character is valid in (the relevant version of) XML */ public static boolean validCharacter(XPathContext c, int in) { return c.getConfiguration().getNameChecker().isValidChar(in); }
private static void checkNormalizationForm(String value) throws XPathException { if (!NameChecker.isValidNmtoken(value)) { throw new XPathException("Invalid value for normalization-form: " + "must be NFC, NFD, NFKC, NFKD, fully-normalized, or none", "SEPM0016"); } }
ch32 = UTF16.combinePair((char)ch32, low); if (!nameChecker.isValidChar(ch32)) { XPathException err = new XPathException("The query file contains a character illegal in XML " + nameChecker.getXMLVersion() + " (line=" + line + " column=" + column +
&& input.charAt(inputOffset) == ':' && inputOffset + 1 < inputLength && (input.charAt(inputOffset + 1) > 127 || NameChecker.isNCNameStartChar(input.charAt(inputOffset + 1)))) { inputOffset++; nextToken = Token.SUFFIX;
/** * Test whether a supplied name is a valid NCName * * @param name the name to be tested * @return true if the name is valid or if checking is disabled */ private boolean isValidNCName(String name) { return !isChecking || NameChecker.isValidNCName(name); }
public static String[] validateQName(String name) throws TeiidProcessingException { try { return NameChecker.getQNameParts(name); } catch (QNameException e) { throw new TeiidProcessingException(e); } }
} else { String typeName = Whitespace.trim(pragmaContents); if (!NameChecker.isQName(typeName)) { grumble("Schema type name expected in saxon:validate-type pragma: found " + Err.wrap(typeName));
AtomicValue val = (AtomicValue)((Literal)elementName).getValue(); if (val instanceof StringValue) { String[] parts = visitor.getConfiguration().getNameChecker().checkQNameParts(val.getStringValueCS()); if (namespace == null) { String prefix = parts[0];
if (!checker.isValidNCName(buff)) { ValidationFailure err = new ValidationFailure("The value '" + val + "' is not a valid Name"); err.setErrorCode("FORG0001"); case StandardNames.XS_IDREF: case StandardNames.XS_ENTITY: if (!checker.isValidNCName(val)) { ValidationFailure err = new ValidationFailure("The value '" + val + "' is not a valid NCName"); err.setErrorCode("FORG0001"); if (!checker.isValidNmtoken(val)) { ValidationFailure err = new ValidationFailure("The value '" + val + "' is not a valid NMTOKEN"); err.setErrorCode("FORG0001");
/** * Check to see if a string is a valid Nmtoken according to [7] * in the XML 1.0 Recommendation * * @param nmtoken string to check * @return true if nmtoken is a valid Nmtoken */ public final boolean isValidNmtoken(CharSequence nmtoken) { if (nmtoken.length() == 0) { return false; } for (int i = 0; i < nmtoken.length(); i++) { char ch = nmtoken.charAt(i); if (ch != ':' && !isNCNameChar(ch)) { return false; } } return true; }