com.sun.tools.internal.xjc.reader.Const Java Examples

The following examples show how to use com.sun.tools.internal.xjc.reader.Const. 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: Internalizer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
Example #2
Source File: Internalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
Example #3
Source File: ModelLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #4
Source File: Internalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Declares a new prefix on the given element and associates it
 * with the specified namespace URI.
 * <p>
 * Note that this method doesn't use the default namespace
 * even if it can.
 */
private String allocatePrefix( Element e, String nsUri ) {
    // look for existing namespaces.
    NamedNodeMap atts = e.getAttributes();
    for( int i=0; i<atts.getLength(); i++ ) {
        Attr a = (Attr)atts.item(i);
        if( Const.XMLNS_URI.equals(a.getNamespaceURI()) ) {
            if( a.getName().indexOf(':')==-1 )  continue;

            if( a.getValue().equals(nsUri) )
                return a.getLocalName();    // found one
        }
    }

    // none found. allocate new.
    while(true) {
        String prefix = "p"+(int)(Math.random()*1000000)+'_';
        if(e.getAttributeNodeNS(Const.XMLNS_URI,prefix)!=null)
            continue;   // this prefix is already allocated.

        e.setAttributeNS(Const.XMLNS_URI,"xmlns:"+prefix,nsUri);
        return prefix;
    }
}
 
Example #5
Source File: Internalizer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Declares a new prefix on the given element and associates it
 * with the specified namespace URI.
 * <p>
 * Note that this method doesn't use the default namespace
 * even if it can.
 */
private String allocatePrefix( Element e, String nsUri ) {
    // look for existing namespaces.
    NamedNodeMap atts = e.getAttributes();
    for( int i=0; i<atts.getLength(); i++ ) {
        Attr a = (Attr)atts.item(i);
        if( Const.XMLNS_URI.equals(a.getNamespaceURI()) ) {
            if( a.getName().indexOf(':')==-1 )  continue;

            if( a.getValue().equals(nsUri) )
                return a.getLocalName();    // found one
        }
    }

    // none found. allocate new.
    while(true) {
        String prefix = "p"+(int)(Math.random()*1000000)+'_';
        if(e.getAttributeNodeNS(Const.XMLNS_URI,prefix)!=null)
            continue;   // this prefix is already allocated.

        e.setAttributeNS(Const.XMLNS_URI,"xmlns:"+prefix,nsUri);
        return prefix;
    }
}
 
Example #6
Source File: Internalizer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
Example #7
Source File: ModelLoader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #8
Source File: Internalizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Declares a new prefix on the given element and associates it
 * with the specified namespace URI.
 * <p>
 * Note that this method doesn't use the default namespace
 * even if it can.
 */
private String allocatePrefix( Element e, String nsUri ) {
    // look for existing namespaces.
    NamedNodeMap atts = e.getAttributes();
    for( int i=0; i<atts.getLength(); i++ ) {
        Attr a = (Attr)atts.item(i);
        if( Const.XMLNS_URI.equals(a.getNamespaceURI()) ) {
            if( a.getName().indexOf(':')==-1 )  continue;

            if( a.getValue().equals(nsUri) )
                return a.getLocalName();    // found one
        }
    }

    // none found. allocate new.
    while(true) {
        String prefix = "p"+(int)(Math.random()*1000000)+'_';
        if(e.getAttributeNodeNS(Const.XMLNS_URI,prefix)!=null)
            continue;   // this prefix is already allocated.

        e.setAttributeNS(Const.XMLNS_URI,"xmlns:"+prefix,nsUri);
        return prefix;
    }
}
 
Example #9
Source File: Internalizer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
Example #10
Source File: Internalizer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Declares a new prefix on the given element and associates it
 * with the specified namespace URI.
 * <p>
 * Note that this method doesn't use the default namespace
 * even if it can.
 */
private String allocatePrefix( Element e, String nsUri ) {
    // look for existing namespaces.
    NamedNodeMap atts = e.getAttributes();
    for( int i=0; i<atts.getLength(); i++ ) {
        Attr a = (Attr)atts.item(i);
        if( Const.XMLNS_URI.equals(a.getNamespaceURI()) ) {
            if( a.getName().indexOf(':')==-1 )  continue;

            if( a.getValue().equals(nsUri) )
                return a.getLocalName();    // found one
        }
    }

    // none found. allocate new.
    while(true) {
        String prefix = "p"+(int)(Math.random()*1000000)+'_';
        if(e.getAttributeNodeNS(Const.XMLNS_URI,prefix)!=null)
            continue;   // this prefix is already allocated.

        e.setAttributeNS(Const.XMLNS_URI,"xmlns:"+prefix,nsUri);
        return prefix;
    }
}
 
Example #11
Source File: Internalizer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Declares a new prefix on the given element and associates it
 * with the specified namespace URI.
 * <p>
 * Note that this method doesn't use the default namespace
 * even if it can.
 */
private String allocatePrefix( Element e, String nsUri ) {
    // look for existing namespaces.
    NamedNodeMap atts = e.getAttributes();
    for( int i=0; i<atts.getLength(); i++ ) {
        Attr a = (Attr)atts.item(i);
        if( Const.XMLNS_URI.equals(a.getNamespaceURI()) ) {
            if( a.getName().indexOf(':')==-1 )  continue;

            if( a.getValue().equals(nsUri) )
                return a.getLocalName();    // found one
        }
    }

    // none found. allocate new.
    while(true) {
        String prefix = "p"+(int)(Math.random()*1000000)+'_';
        if(e.getAttributeNodeNS(Const.XMLNS_URI,prefix)!=null)
            continue;   // this prefix is already allocated.

        e.setAttributeNS(Const.XMLNS_URI,"xmlns:"+prefix,nsUri);
        return prefix;
    }
}
 
Example #12
Source File: DOMBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
    super.startElement(namespaceURI, localName, qName, atts);

    Element e = getCurrentElement();
    locatorTable.storeStartLocation( e, locator );

    // check if this element is an outer-most <jaxb:bindings>
    if( Const.JAXB_NSURI.equals(e.getNamespaceURI())
    &&  "bindings".equals(e.getLocalName()) ) {

        // if this is the root node (meaning that this file is an
        // external binding file) or if the parent is XML Schema element
        // (meaning that this is an "inlined" external binding)
        Node p = e.getParentNode();
        if( p instanceof Document
        ||( p instanceof Element && !e.getNamespaceURI().equals(p.getNamespaceURI()))) {
            outerMostBindings.add(e);   // remember this value
        }
    }
}
 
Example #13
Source File: Internalizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
Example #14
Source File: Internalizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
Example #15
Source File: ModelLoader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #16
Source File: ModelLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #17
Source File: ModelLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses a RELAX NG grammar into an annotated grammar.
 */
private Model loadRELAXNG() throws SAXException {

    // build DOM forest
    final DOMForest forest = buildDOMForest( new RELAXNGInternalizationLogic() );

    // use JAXP masquerading to validate the input document.
    // DOMForest -> ExtensionBindingChecker -> RNGOM

    XMLReaderCreator xrc = new XMLReaderCreator() {
        public XMLReader createXMLReader() {

            // foreset parser cannot change the receivers while it's working,
            // so we need to have one XMLFilter that works as a buffer
            XMLFilter buffer = new XMLFilterImpl() {
                @Override
                public void parse(InputSource source) throws IOException, SAXException {
                    forest.createParser().parse( source, this, this, this );
                }
            };

            XMLFilter f = new ExtensionBindingChecker(Const.RELAXNG_URI,opt,errorReceiver);
            f.setParent(buffer);

            f.setEntityResolver(opt.entityResolver);

            return f;
        }
    };

    Parseable p = new SAXParseable( opt.getGrammars()[0], errorReceiver, xrc );

    return loadRELAXNG(p);

}
 
Example #18
Source File: IncorrectNamespaceURIChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    throws SAXException {
    super.startElement(namespaceURI, localName, qName, atts);

    // I'm not sure if this is necessary (SAX might report the change of the default prefix
    // through the startPrefixMapping method, and I think it does indeed.)
    //
    // but better safe than sorry.

    if( namespaceURI.equals(Const.JAXB_NSURI) )
        isCustomizationUsed = true;
}
 
Example #19
Source File: UnusedCustomizationChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void checkExpectedContentTypes(XSComponent c) {
    if(c.getForeignAttribute(WellKnownNamespace.XML_MIME_URI, Const.EXPECTED_CONTENT_TYPES)==null)
        return; // no such attribute
    if(c instanceof XSParticle)
        return; // particles get the same foreign attributes as local element decls,
                // so we need to skip them

    if(!stb.isAcknowledgedXmimeContentTypes(c)) {
        // this is not used
        getErrorReporter().warning(c.getLocator(),Messages.WARN_UNUSED_EXPECTED_CONTENT_TYPES);
    }
}
 
Example #20
Source File: Internalizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Recursively visits sub-elements and declare all used namespaces.
 * TODO: the fact that we recognize all namespaces in the extension
 * is a bad design.
 */
private void declExtensionNamespace(Element decl, Element target) {
    // if this comes from external namespaces, add the namespace to
    // @extensionBindingPrefixes.
    if( !Const.JAXB_NSURI.equals(decl.getNamespaceURI()) )
        declareExtensionNamespace( target, decl.getNamespaceURI() );

    NodeList lst = decl.getChildNodes();
    for( int i=0; i<lst.getLength(); i++ ) {
        Node n = lst.item(i);
        if( n instanceof Element )
            declExtensionNamespace( (Element)n, target );
    }
}
 
Example #21
Source File: DTDExtensionBindingChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if the elements with the given namespace URI
 * should be blocked by this filter.
 */
private boolean needsToBePruned( String uri ) {
    if( uri.equals(schemaLanguage) )
        return false;
    if( uri.equals(Const.JAXB_NSURI) )
        return false;
    if( uri.equals(Const.XJC_EXTENSION_URI) )
        return false;
    // we don't want validator to see extensions that we understand ,
    // because they will complain.
    // OTOH, if  this is an extension that we didn't understand,
    // we want the validator to report an error
    return enabledExtensions.contains(uri);
}
 
Example #22
Source File: IncorrectNamespaceURIChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
    if (WellKnownNamespace.XML_NAMESPACE_URI.equals(uri)) return; //xml prefix shall not be declared based on jdk api javadoc
    if( prefix.equals("jaxb") )
        isJAXBPrefixUsed = true;
    if( uri.equals(Const.JAXB_NSURI) )
        isCustomizationUsed = true;

    super.startPrefixMapping(prefix, uri);
}
 
Example #23
Source File: CustomizationContextChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
    QName newElement = new QName(namespaceURI,localName);

    if( newElement.getNamespaceURI().equals(Const.JAXB_NSURI)
     && top().getNamespaceURI().equals(WellKnownNamespace.XML_SCHEMA) ) {
        // we hit a JAXB customization. the stack top should be
        // <xs:appinfo>
        if( elementNames.size()>=3 ) {
            // the above statement checks if the following statement doesn't
            // cause an exception.
            QName schemaElement = elementNames.get( elementNames.size()-3 );
            if( prohibitedSchemaElementNames.contains(schemaElement.getLocalPart()) ) {
                // the owner schema element is in the wanted list.
                errorHandler.error( new SAXParseException(
                    Messages.format(
                        Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION,
                        localName ),
                    locator ) );
            }
        }


    }

    elementNames.push(newElement);

    super.startElement(namespaceURI, localName, qName, atts );
}
 
Example #24
Source File: Internalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Recursively visits sub-elements and declare all used namespaces.
 * TODO: the fact that we recognize all namespaces in the extension
 * is a bad design.
 */
private void declExtensionNamespace(Element decl, Element target) {
    // if this comes from external namespaces, add the namespace to
    // @extensionBindingPrefixes.
    if( !Const.JAXB_NSURI.equals(decl.getNamespaceURI()) )
        declareExtensionNamespace( target, decl.getNamespaceURI() );

    NodeList lst = decl.getChildNodes();
    for( int i=0; i<lst.getLength(); i++ ) {
        Node n = lst.item(i);
        if( n instanceof Element )
            declExtensionNamespace( (Element)n, target );
    }
}
 
Example #25
Source File: Internalizer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Recursively visits sub-elements and declare all used namespaces.
 * TODO: the fact that we recognize all namespaces in the extension
 * is a bad design.
 */
private void declExtensionNamespace(Element decl, Element target) {
    // if this comes from external namespaces, add the namespace to
    // @extensionBindingPrefixes.
    if( !Const.JAXB_NSURI.equals(decl.getNamespaceURI()) )
        declareExtensionNamespace( target, decl.getNamespaceURI() );

    NodeList lst = decl.getChildNodes();
    for( int i=0; i<lst.getLength(); i++ ) {
        Node n = lst.item(i);
        if( n instanceof Element )
            declExtensionNamespace( (Element)n, target );
    }
}
 
Example #26
Source File: IncorrectNamespaceURIChecker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
    if (WellKnownNamespace.XML_NAMESPACE_URI.equals(uri)) return; //xml prefix shall not be declared based on jdk api javadoc
    if( prefix.equals("jaxb") )
        isJAXBPrefixUsed = true;
    if( uri.equals(Const.JAXB_NSURI) )
        isCustomizationUsed = true;

    super.startPrefixMapping(prefix, uri);
}
 
Example #27
Source File: IncorrectNamespaceURIChecker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    throws SAXException {
    super.startElement(namespaceURI, localName, qName, atts);

    // I'm not sure if this is necessary (SAX might report the change of the default prefix
    // through the startPrefixMapping method, and I think it does indeed.)
    //
    // but better safe than sorry.

    if( namespaceURI.equals(Const.JAXB_NSURI) )
        isCustomizationUsed = true;
}
 
Example #28
Source File: IncorrectNamespaceURIChecker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    throws SAXException {
    super.startElement(namespaceURI, localName, qName, atts);

    // I'm not sure if this is necessary (SAX might report the change of the default prefix
    // through the startPrefixMapping method, and I think it does indeed.)
    //
    // but better safe than sorry.

    if( namespaceURI.equals(Const.JAXB_NSURI) )
        isCustomizationUsed = true;
}
 
Example #29
Source File: VersionChecker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    throws SAXException {

    super.startElement(namespaceURI, localName, qName, atts);

    if(!seenRoot) {
        // if this is the root element
        seenRoot = true;
        rootTagStart = new LocatorImpl(locator);

        version = atts.getValue(Const.JAXB_NSURI,"version");
        if( namespaceURI.equals(Const.JAXB_NSURI) ) {
            String version2 = atts.getValue("","version");
            if( version!=null && version2!=null ) {
                // we have both @version and @jaxb:version. error.
                SAXParseException e = new SAXParseException(
                    Messages.format( Messages.TWO_VERSION_ATTRIBUTES ), locator );
                getErrorHandler().error(e);
            }
            if( version==null )
                version = version2;
        }

    }

    if( Const.JAXB_NSURI.equals(namespaceURI) )
        seenBindings = true;
}
 
Example #30
Source File: DTDExtensionBindingChecker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if the elements with the given namespace URI
 * should be blocked by this filter.
 */
private boolean needsToBePruned( String uri ) {
    if( uri.equals(schemaLanguage) )
        return false;
    if( uri.equals(Const.JAXB_NSURI) )
        return false;
    if( uri.equals(Const.XJC_EXTENSION_URI) )
        return false;
    // we don't want validator to see extensions that we understand ,
    // because they will complain.
    // OTOH, if  this is an extension that we didn't understand,
    // we want the validator to report an error
    return enabledExtensions.contains(uri);
}