Java Code Examples for com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util#isLiteral()

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util#isLiteral() . 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 File: ProcessingInstruction.java    From jdk1.8-source-analysis with Apache License 2.0 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 2
Source File: ProcessingInstruction.java    From openjdk-8-source with GNU General Public License v2.0 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 3
Source File: ProcessingInstruction.java    From hottub with GNU General Public License v2.0 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 4
Source File: ProcessingInstruction.java    From openjdk-jdk9 with GNU General Public License v2.0 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 5
Source File: ProcessingInstruction.java    From Bytecoder with Apache License 2.0 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 6
Source File: ProcessingInstruction.java    From openjdk-8 with GNU General Public License v2.0 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 7
Source File: ProcessingInstruction.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 8
Source File: ProcessingInstruction.java    From openjdk-jdk8u with GNU General Public License v2.0 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 9
Source File: ProcessingInstruction.java    From JDKSourceCode1.8 with 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 10
Source File: ProcessingInstruction.java    From jdk8u60 with GNU General Public License v2.0 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 11
Source File: ProcessingInstruction.java    From TencentKona-8 with GNU General Public License v2.0 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 12
Source File: XslAttribute.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 13
Source File: XslAttribute.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 14
Source File: XslAttribute.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 15
Source File: XslAttribute.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final Vector siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = (SyntaxTreeNode)siblings.elementAt(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 16
Source File: XslAttribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 17
Source File: XslAttribute.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 18
Source File: XslAttribute.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 19
Source File: XslAttribute.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final Vector siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = (SyntaxTreeNode)siblings.elementAt(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}
 
Example 20
Source File: XslAttribute.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Parses the attribute's contents. Special care taken for namespaces.
 */
public void parseContents(Parser parser) {
    boolean generated = false;
    final SymbolTable stable = parser.getSymbolTable();

    String name = getAttribute("name");
    String namespace = getAttribute("namespace");
    QName qname = parser.getQName(name, false);
    final String prefix = qname.getPrefix();

    if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) {
        reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
        return;
    }

    _isLiteral = Util.isLiteral(name);
    if (_isLiteral) {
        if (!XML11Char.isXML11ValidQName(name)) {
            reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name);
            return;
        }
    }

    // Ignore attribute if preceeded by some other type of element
    final SyntaxTreeNode parent = getParent();
    final List<SyntaxTreeNode> siblings = parent.getContents();
    for (int i = 0; i < parent.elementCount(); i++) {
        SyntaxTreeNode item = siblings.get(i);
        if (item == this) break;

        // These three objects result in one or more attribute output
        if (item instanceof XslAttribute) continue;
        if (item instanceof UseAttributeSets) continue;
        if (item instanceof LiteralAttribute) continue;
        if (item instanceof Text) continue;

        // These objects _can_ result in one or more attribute
        // The output handler will generate an error if not (at runtime)
        if (item instanceof If) continue;
        if (item instanceof Choose) continue;
        if (item instanceof CopyOf) continue;
        if (item instanceof VariableBase) continue;

        // Report warning but do not ignore attribute
        reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name);
    }

    // Get namespace from namespace attribute?
    if (namespace != null && namespace != Constants.EMPTYSTRING) {
        _prefix = lookupPrefix(namespace);
        _namespace = new AttributeValueTemplate(namespace, parser, this);
    }
    // Get namespace from prefix in name attribute?
    else if (prefix != null && prefix != Constants.EMPTYSTRING) {
        _prefix = prefix;
        namespace = lookupNamespace(prefix);
        if (namespace != null) {
            _namespace = new AttributeValueTemplate(namespace, parser, this);
        }
    }

    // Common handling for namespaces:
    if (_namespace != null) {
        // Generate prefix if we have none
        if (_prefix == null || _prefix == Constants.EMPTYSTRING) {
            if (prefix != null) {
                _prefix = prefix;
            }
            else {
                _prefix = stable.generateNamespacePrefix();
                generated = true;
            }
        }
        else if (prefix != null && !prefix.equals(_prefix)) {
            _prefix = prefix;
        }

        name = _prefix + ":" + qname.getLocalPart();

        /*
         * TODO: The namespace URI must be passed to the parent
         * element but we don't yet know what the actual URI is
         * (as we only know it as an attribute value template).
         */
        if ((parent instanceof LiteralElement) && (!generated)) {
            ((LiteralElement)parent).registerNamespace(_prefix,
                                                       namespace,
                                                       stable, false);
        }
    }

    if (parent instanceof LiteralElement) {
        ((LiteralElement)parent).addAttribute(this);
    }

    _name = AttributeValue.create(this, name, parser);
    parseChildren(parser);
}