Java Code Examples for com.sun.org.apache.xml.internal.utils.XML11Char

The following examples show how to use com.sun.org.apache.xml.internal.utils.XML11Char. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk1.8-source-analysis   Source File: DecimalFormatting.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: WithParam.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The contents of a <xsl:with-param> elements are either in the element's
 * 'select' attribute (this has precedence) or in the element body.
 */
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
                                        this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    }
    else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }

    final String select = getAttribute("select");
    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);
    }

    parseChildren(parser);
}
 
Example 3
Source Project: jdk1.8-source-analysis   Source File: ApplyTemplates.java    License: Apache License 2.0 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 4
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 5
Source Project: TencentKona-8   Source File: WithParam.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * The contents of a <xsl:with-param> elements are either in the element's
 * 'select' attribute (this has precedence) or in the element body.
 */
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
                                        this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    } else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }

    final String select = getAttribute("select");
    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);
    }

    parseChildren(parser);
}
 
Example 6
Source Project: TencentKona-8   Source File: ApplyTemplates.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 7
public void parseContents(Parser parser) {
    final String name  = getAttribute("name");

    if (name.length() > 0) {
        _isLiteral = Util.isLiteral(name);
        if (_isLiteral) {
            if (!XML11Char.isXML11ValidNCName(name)) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_NCNAME_ERR, name, this);
                parser.reportError(Constants.ERROR, err);
            }
        }
        _name = AttributeValue.create(this, name, parser);
    }
    else
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    if (name.equals("xml")) {
        reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
    }
    parseChildren(parser);
}
 
Example 8
Source Project: jdk8u60   Source File: DecimalFormatting.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 9
Source Project: jdk8u60   Source File: WithParam.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * The contents of a <xsl:with-param> elements are either in the element's
 * 'select' attribute (this has precedence) or in the element body.
 */
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
                                        this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    }
    else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }

    final String select = getAttribute("select");
    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);
    }

    parseChildren(parser);
}
 
Example 10
Source Project: jdk8u60   Source File: ApplyTemplates.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 11
public void parseContents(Parser parser) {
    final String name  = getAttribute("name");

    if (name.length() > 0) {
        _isLiteral = Util.isLiteral(name);
        if (_isLiteral) {
            if (!XML11Char.isXML11ValidNCName(name)) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_NCNAME_ERR, name, this);
                parser.reportError(Constants.ERROR, err);
            }
        }
        _name = AttributeValue.create(this, name, parser);
    }
    else
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    if (name.equals("xml")) {
        reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
    }
    parseChildren(parser);
}
 
Example 12
Source Project: JDKSourceCode1.8   Source File: DecimalFormatting.java    License: MIT License 6 votes vote down vote up
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 13
Source Project: JDKSourceCode1.8   Source File: WithParam.java    License: MIT License 6 votes vote down vote up
/**
 * The contents of a <xsl:with-param> elements are either in the element's
 * 'select' attribute (this has precedence) or in the element body.
 */
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
                                        this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    } else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }

    final String select = getAttribute("select");
    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);
    }

    parseChildren(parser);
}
 
Example 14
Source Project: Bytecoder   Source File: ApplyTemplates.java    License: Apache License 2.0 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 15
Source Project: JDKSourceCode1.8   Source File: ProcessingInstruction.java    License: MIT License 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String name  = getAttribute("name");

    if (name.length() > 0) {
        _isLiteral = Util.isLiteral(name);
        if (_isLiteral) {
            if (!XML11Char.isXML11ValidNCName(name)) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_NCNAME_ERR, name, this);
                parser.reportError(Constants.ERROR, err);
            }
        }
        _name = AttributeValue.create(this, name, parser);
    }
    else
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    if (name.equals("xml")) {
        reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
    }
    parseChildren(parser);
}
 
Example 16
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 17
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 18
Source Project: openjdk-jdk8u   Source File: ApplyTemplates.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 19
public void parseContents(Parser parser) {
    final String name  = getAttribute("name");

    if (name.length() > 0) {
        _isLiteral = Util.isLiteral(name);
        if (_isLiteral) {
            if (!XML11Char.isXML11ValidNCName(name)) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_NCNAME_ERR, name, this);
                parser.reportError(Constants.ERROR, err);
            }
        }
        _name = AttributeValue.create(this, name, parser);
    }
    else
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    if (name.equals("xml")) {
        reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
    }
    parseChildren(parser);
}
 
Example 20
/**
 * The contents of a <xsl:with-param> elements are either in the element's
 * 'select' attribute (this has precedence) or in the element body.
 */
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
                                        this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    } else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }

    final String select = getAttribute("select");
    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);
    }

    parseChildren(parser);
}
 
Example 21
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 22
public void parseContents(Parser parser) {
    final String name  = getAttribute("name");

    if (name.length() > 0) {
        _isLiteral = Util.isLiteral(name);
        if (_isLiteral) {
            if (!XML11Char.isXML11ValidNCName(name)) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_NCNAME_ERR, name, this);
                parser.reportError(Constants.ERROR, err);
            }
        }
        _name = AttributeValue.create(this, name, parser);
    }
    else
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    if (name.equals("xml")) {
        reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
    }
    parseChildren(parser);
}
 
Example 23
Source Project: openjdk-jdk9   Source File: ApplyTemplates.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void parseContents(Parser parser) {
    final String select = getAttribute("select");
    final String mode   = getAttribute("mode");

    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);

    }

    if (mode.length() > 0) {
        if (!XML11Char.isXML11ValidQName(mode)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this);
            parser.reportError(Constants.ERROR, err);
        }
        _modeName = parser.getQNameIgnoreDefaultNs(mode);
    }

    // instantiate Mode if needed, cache (apply temp) function name
    _functionName =
        parser.getTopLevelStylesheet().getMode(_modeName).functionName();
    parseChildren(parser);// with-params
}
 
Example 24
Source Project: Bytecoder   Source File: DecimalFormatting.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parse the name of the <xsl:decimal-formatting/> element
 */
public void parseContents(Parser parser) {
    // Get the name of these decimal formatting symbols
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)){
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
    }
    _name = parser.getQNameIgnoreDefaultNs(name);
    if (_name == null) {
        _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING);
    }

    // Check if a set of symbols has already been registered under this name
    SymbolTable stable = parser.getSymbolTable();
    if (stable.getDecimalFormatting(_name) != null) {
        reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR,
            _name.toString());
    }
    else {
        stable.addDecimalFormatting(_name, this);
    }
}
 
Example 25
Source Project: Bytecoder   Source File: WithParam.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The contents of a <xsl:with-param> elements are either in the element's
 * 'select' attribute (this has precedence) or in the element body.
 */
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
                                        this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    } else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }

    final String select = getAttribute("select");
    if (select.length() > 0) {
        _select = parser.parseExpression(this, "select", null);
    }

    parseChildren(parser);
}
 
Example 26
Source Project: jdk1.8-source-analysis   Source File: BasisLibrary.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Utility function to check if xsl:attribute has a valid qname
 * This method should only be invoked if the name attribute is an AVT
 */
public static void checkAttribQName(String name) {
    final int firstOccur = name.indexOf(":");
    final int lastOccur = name.lastIndexOf(":");
    final String localName = name.substring(lastOccur + 1);

    if (firstOccur > 0) {
        final String newPrefix = name.substring(0, firstOccur);

        if (firstOccur != lastOccur) {
           final String oriPrefix = name.substring(firstOccur+1, lastOccur);
            if (!XML11Char.isXML11ValidNCName(oriPrefix)) {
                // even though the orignal prefix is ignored, it should still get checked for valid NCName
                runTimeError(INVALID_QNAME_ERR,oriPrefix+":"+localName);
            }
        }

        // prefix must be a valid NCName
        if (!XML11Char.isXML11ValidNCName(newPrefix)) {
            runTimeError(INVALID_QNAME_ERR,newPrefix+":"+localName);
        }
    }

    // local name must be a valid NCName and must not be XMLNS
    if ((!XML11Char.isXML11ValidNCName(localName))||(localName.equals(Constants.XMLNS_PREFIX))) {
        runTimeError(INVALID_QNAME_ERR,localName);
    }
}
 
Example 27
Source Project: jdk1.8-source-analysis   Source File: VariableBase.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Parse the contents of the <xsl:decimal-format> element.
 */
public void parseContents(Parser parser) {
    // Get the 'name attribute
    String name = getAttribute("name");

    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
        setName(parser.getQNameIgnoreDefaultNs(name));
    }
    else
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    // Check whether variable/param of the same name is already in scope
    VariableBase other = parser.lookupVariable(_name);
    if ((other != null) && (other.getParent() == getParent())) {
        reportError(this, parser, ErrorMsg.VARIABLE_REDEF_ERR, name);
    }

    select = getAttribute("select");
    if (select.length() > 0) {
        _select = getParser().parseExpression(this, "select", null);
        if (_select.isDummy()) {
            reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select");
            return;
        }
    }

    // Children must be parsed first -> static scoping
    parseChildren(parser);
}
 
Example 28
Source Project: jdk1.8-source-analysis   Source File: CallTemplate.java    License: Apache License 2.0 5 votes vote down vote up
public void parseContents(Parser parser) {
    final String name = getAttribute("name");
    if (name.length() > 0) {
        if (!XML11Char.isXML11ValidQName(name)) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this);
            parser.reportError(Constants.ERROR, err);
        }
        _name = parser.getQNameIgnoreDefaultNs(name);
    }
    else {
        reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
    }
    parseChildren(parser);
}
 
Example 29
Source Project: jdk1.8-source-analysis   Source File: Util.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the string is valid list of qnames
 */
public static boolean isValidQNames(String str) {
    if ((str != null) && (!str.equals(Constants.EMPTYSTRING))) {
        final StringTokenizer tokens = new StringTokenizer(str);
        while (tokens.hasMoreTokens()) {
            if (!XML11Char.isXML11ValidQName(tokens.nextToken())) {
                return false;
            }
        }
    }
    return true;
}
 
Example 30
Source Project: TencentKona-8   Source File: BasisLibrary.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function to check if xsl:attribute has a valid qname
 * This method should only be invoked if the name attribute is an AVT
 */
public static void checkAttribQName(String name) {
    final int firstOccur = name.indexOf(':');
    final int lastOccur = name.lastIndexOf(':');
    final String localName = name.substring(lastOccur + 1);

    if (firstOccur > 0) {
        final String newPrefix = name.substring(0, firstOccur);

        if (firstOccur != lastOccur) {
           final String oriPrefix = name.substring(firstOccur+1, lastOccur);
            if (!XML11Char.isXML11ValidNCName(oriPrefix)) {
                // even though the orignal prefix is ignored, it should still get checked for valid NCName
                runTimeError(INVALID_QNAME_ERR,oriPrefix+":"+localName);
            }
        }

        // prefix must be a valid NCName
        if (!XML11Char.isXML11ValidNCName(newPrefix)) {
            runTimeError(INVALID_QNAME_ERR,newPrefix+":"+localName);
        }
    }

    // local name must be a valid NCName and must not be XMLNS
    if ((!XML11Char.isXML11ValidNCName(localName))||(localName.equals(Constants.XMLNS_PREFIX))) {
        runTimeError(INVALID_QNAME_ERR,localName);
    }
}