protected String readCollationName() throws XPathException { nextToken(); expect(Token.STRING_LITERAL); String collationName = uriLiteral(t.currentTokenValue); URI collationURI; try { collationURI = new URI(collationName); if (!collationURI.isAbsolute()) { URI base = new URI(env.getStaticBaseURI()); collationURI = base.resolve(collationURI); collationName = collationURI.toString(); } } catch (URISyntaxException err) { grumble("Collation name '" + collationName + "' is not a valid URI", "XQST0046"); collationName = NamespaceConstant.CODEPOINT_COLLATION_URI; } nextToken(); return collationName; }
protected String readCollationName() throws XPathException { nextToken(); expect(Token.STRING_LITERAL); String collationName = uriLiteral(t.currentTokenValue); URI collationURI; try { collationURI = new URI(collationName); if (!collationURI.isAbsolute()) { URI base = new URI(env.getStaticBaseURI()); collationURI = base.resolve(collationURI); collationName = collationURI.toString(); } } catch (URISyntaxException err) { grumble("Collation name '" + collationName + "' is not a valid URI", "XQST0046"); collationName = NamespaceConstant.CODEPOINT_COLLATION_URI; } nextToken(); return collationName; }
private List<SequenceType> parseSequenceTypeList() throws XPathException { List<SequenceType> typeList = new ArrayList<>(); while (true) { SequenceType type = parseSequenceType(); typeList.add(type); t.treatCurrentAsOperator(); if (t.currentToken == Token.UNION) { nextToken(); } else { break; } } expect(Token.RETURN); nextToken(); return typeList; }
private List<SequenceType> parseSequenceTypeList() throws XPathException { List<SequenceType> typeList = new ArrayList<>(); while (true) { SequenceType type = parseSequenceType(); typeList.add(type); t.treatCurrentAsOperator(); if (t.currentToken == Token.UNION) { nextToken(); } else { break; } } expect(Token.RETURN); nextToken(); return typeList; }
/** * Parse the "declare ordering" declaration. * Syntax: <"declare" "ordering"> ("ordered" | "unordered") * * @throws XPathException if parsing fails */ private void parseOrderingDeclaration() throws XPathException { if (foundOrderingDeclaration) { grumble("ordering mode declaration appears more than once", "XQST0065"); } foundOrderingDeclaration = true; nextToken(); expect(Token.NAME); if ("ordered".equals(t.currentTokenValue)) { // no action } else if ("unordered".equals(t.currentTokenValue)) { // no action } else { grumble("ordering mode must be 'ordered' or 'unordered'"); } nextToken(); }
/** * Parse the "default function namespace" declaration. * Syntax: <"declare" "default" "function" "namespace"> StringLiteral * * @throws XPathException to indicate a syntax error */ private void parseDefaultFunctionNamespace() throws XPathException { if (foundDefaultFunctionNamespace) { grumble("default function namespace appears more than once", "XQST0066"); } foundDefaultFunctionNamespace = true; nextToken(); expect(Token.NAME); if (!"namespace".equals(t.currentTokenValue)) { grumble("After 'declare default function', expected 'namespace'"); } nextToken(); expect(Token.STRING_LITERAL); String uri = uriLiteral(t.currentTokenValue); if (uri.equals(NamespaceConstant.XML) || uri.equals(NamespaceConstant.XMLNS)) { grumble("Reserved namespace used as default element/type namespace", "XQST0070"); } ((QueryModule) env).setDefaultFunctionNamespace(uri); nextToken(); }
/** * Parse the "declare xmlspace" declaration. * Syntax: <"declare" "boundary-space"> ("preserve" | "strip") * * @throws XPathException if a static error is encountered */ private void parseBoundarySpaceDeclaration() throws XPathException { if (foundBoundarySpaceDeclaration) { grumble("'declare boundary-space' appears more than once", "XQST0068"); } foundBoundarySpaceDeclaration = true; nextToken(); expect(Token.NAME); if ("preserve".equals(t.currentTokenValue)) { ((QueryModule) env).setPreserveBoundarySpace(true); } else if ("strip".equals(t.currentTokenValue)) { ((QueryModule) env).setPreserveBoundarySpace(false); } else { grumble("boundary-space must be 'preserve' or 'strip'"); } nextToken(); }
private void parseDefaultCollation() throws XPathException { // <"default" "collation"> StringLiteral if (foundDefaultCollation) { grumble("default collation appears more than once", "XQST0038"); } foundDefaultCollation = true; nextToken(); expect(Token.STRING_LITERAL); String uri = uriLiteral(t.currentTokenValue); ((QueryModule) env).setDefaultCollationName(uri); nextToken(); }
/** * Parse the "declare xmlspace" declaration. * Syntax: <"declare" "boundary-space"> ("preserve" | "strip") * * @throws XPathException if a static error is encountered */ private void parseBoundarySpaceDeclaration() throws XPathException { if (foundBoundarySpaceDeclaration) { grumble("'declare boundary-space' appears more than once", "XQST0068"); } foundBoundarySpaceDeclaration = true; nextToken(); expect(Token.NAME); if ("preserve".equals(t.currentTokenValue)) { ((QueryModule) env).setPreserveBoundarySpace(true); } else if ("strip".equals(t.currentTokenValue)) { ((QueryModule) env).setPreserveBoundarySpace(false); } else { grumble("boundary-space must be 'preserve' or 'strip'"); } nextToken(); }
private void parseDefaultCollation() throws XPathException { // <"default" "collation"> StringLiteral if (foundDefaultCollation) { grumble("default collation appears more than once", "XQST0038"); } foundDefaultCollation = true; nextToken(); expect(Token.STRING_LITERAL); String uri = uriLiteral(t.currentTokenValue); ((QueryModule) env).setDefaultCollationName(uri); nextToken(); }
private Expression parseCommentConstructor(int offset) throws XPathException { nextToken(); Expression value; if (t.currentToken == Token.RCURLY && allowXPath31Syntax) { value = Literal.makeEmptySequence(); } else { value = parseExpression(); } expect(Token.RCURLY); lookAhead(); // after an RCURLY nextToken(); Comment com = new Comment(); makeSimpleContent(value, com, offset); return makeTracer(offset, com, StandardNames.XSL_COMMENT, null); }
/** * Parse a named decimal format declaration. * "declare" "decimal-format" QName (property "=" string-literal)* * * @throws XPathException if parsing fails */ private void parseDecimalFormatDeclaration() throws XPathException { nextToken(); expect(Token.NAME); StructuredQName formatName = makeStructuredQName(t.currentTokenValue, ""); if (env.getDecimalFormatManager().getNamedDecimalFormat(formatName) != null) { grumble("Duplicate declaration of decimal-format " + formatName.getDisplayName(), "XQST0111"); } nextToken(); parseDecimalFormatProperties(formatName); }
private Expression parseCommentConstructor(int offset) throws XPathException { nextToken(); Expression value; if (t.currentToken == Token.RCURLY && allowXPath31Syntax) { value = Literal.makeEmptySequence(); } else { value = parseExpression(); } expect(Token.RCURLY); lookAhead(); // after an RCURLY nextToken(); Comment com = new Comment(); makeSimpleContent(value, com, offset); return makeTracer(offset, com, StandardNames.XSL_COMMENT, null); }
/** * Parse a named decimal format declaration. * "declare" "decimal-format" QName (property "=" string-literal)* * * @throws XPathException if parsing fails */ private void parseDecimalFormatDeclaration() throws XPathException { nextToken(); expect(Token.NAME); StructuredQName formatName = makeStructuredQName(t.currentTokenValue, ""); if (env.getDecimalFormatManager().getNamedDecimalFormat(formatName) != null) { grumble("Duplicate declaration of decimal-format " + formatName.getDisplayName(), "XQST0111"); } nextToken(); parseDecimalFormatProperties(formatName); }
private Expression parseTextNodeConstructor(int offset) throws XPathException { nextToken(); Expression value; if (t.currentToken == Token.RCURLY && allowXPath31Syntax) { value = Literal.makeEmptySequence(); } else { value = parseExpression(); } expect(Token.RCURLY); lookAhead(); // after an RCURLY nextToken(); Expression select = stringify(value, true, env); ValueOf vof = new ValueOf(select, false, true); setLocation(vof, offset); return makeTracer(offset, vof, StandardNames.XSL_TEXT, null); }
private Expression parseTextNodeConstructor(int offset) throws XPathException { nextToken(); Expression value; if (t.currentToken == Token.RCURLY && allowXPath31Syntax) { value = Literal.makeEmptySequence(); } else { value = parseExpression(); } expect(Token.RCURLY); lookAhead(); // after an RCURLY nextToken(); Expression select = stringify(value, true, env); ValueOf vof = new ValueOf(select, false, true); setLocation(vof, offset); return makeTracer(offset, vof, StandardNames.XSL_TEXT, null); }