Package org.xml.sax.ext

Examples of org.xml.sax.ext.Attributes2


            token.qName = qName;

            // The XML parser tends to reuse the same Attributes object, so
            // capture the data out of it.

            Attributes2 a2 = (attributes instanceof Attributes2) ? (Attributes2) attributes : null;

            if (attributes.getLength() == 0)
            {
                token.attributes = Collections.emptyList();
            } else
            {
                token.attributes = CollectionFactory.newList();

                for (int i = 0; i < attributes.getLength(); i++)
                {
                    // Filter out attributes that are not present in the XML input stream, but were
                    // instead provided by DTD defaulting.

                    if (a2 != null && !a2.isSpecified(i))
                    {
                        continue;
                    }

                    String prefixedName = attributes.getQName(i);
View Full Code Here


            token.qName = qName;

            // The XML parser tends to reuse the same Attributes object, so
            // capture the data out of it.

            Attributes2 a2 = (attributes instanceof Attributes2) ? (Attributes2) attributes : null;

            if (attributes.getLength() == 0)
            {
                token.attributes = Collections.emptyList();
            } else
            {
                token.attributes = CollectionFactory.newList();

                for (int i = 0; i < attributes.getLength(); i++)
                {
                    // Filter out attributes that are not present in the XML input stream, but were
                    // instead provided by DTD defaulting.

                    if (a2 != null && !a2.isSpecified(i))
                    {
                        continue;
                    }

                    String prefixedName = attributes.getQName(i);
View Full Code Here

            token.qName = qName;

            // The XML parser tends to reuse the same Attributes object, so
            // capture the data out of it.

            Attributes2 a2 = (attributes instanceof Attributes2) ? (Attributes2) attributes : null;

            if (attributes.getLength() == 0)
            {
                token.attributes = Collections.emptyList();
            } else
            {
                token.attributes = CollectionFactory.newList();

                for (int i = 0; i < attributes.getLength(); i++)
                {
                    // Filter out attributes that are not present in the XML input stream, but were
                    // instead provided by DTD defaulting.

                    if (a2 != null && !a2.isSpecified(i))
                    {
                        continue;
                    }

                    String prefixedName = attributes.getQName(i);
View Full Code Here

    /**
     * @see org.xml.sax.helpers.XMLFilterImpl#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
     */
    @Override
    public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
        Attributes2 atts2 = (Attributes2) atts;
        int idIndex = -1;
        int xmlIdIndex = -1;
        String xmlIdValue = null;
        boolean needsWrap = false;
        int len = atts2.getLength();
        for (int i = 0; i < len; i++) {
            String ns = atts2.getURI(i);
            String local = atts2.getLocalName(i);
            String type = atts2.getType(i);
            if ("id" == local && "" == ns && "http://www.xml-cml.org/schema" != uri) {
                idIndex = i;
                checkId("id", atts2.getValue(i));
                if ("ID" != type) {
                    needsWrap = true;
                }
            } else if ("id" == local && "http://www.w3.org/XML/1998/namespace" == ns) {
                xmlIdIndex = i;
                String value = atts2.getValue(i);
                String normalizedValue = avNormalize(value);
                if (value != normalizedValue) {
                    xmlIdValue = normalizedValue;
                    needsWrap = true;
                }
                Matcher m = NCNAME_PATTERN.matcher(normalizedValue);
                if (!m.matches()) {
                    super.error(new SAXParseException("\u201C" + normalizedValue + "\u201D is not a Namespaces in XML 1.0 NCName.", locator));                   
                }
                if ("ID" != type) {
                    needsWrap = true;
                    if (atts2.isDeclared(i)) {
                        super.error(new SAXParseException("The attribute \u201Cxml:id\u201D was declared to be of type " + type + "in the DTD although it is required to be declared to be of type ID.", locator));                                           
                    }
                }
                checkId("xml:id", normalizedValue);
            } else if ("ID" == type) {
                String qn = atts2.getQName(i);
                super.warning(new SAXParseException("Unusual attribute \u201C" + qn + "\u201D declared be of type ID. This may be a compatibility problem when the DTD is not processed.", locator));
                checkId(qn, atts2.getValue(i));
            }
        }
        if (needsWrap) {
            wrapper.setFields(atts, xmlIdIndex, idIndex, xmlIdValue);
            super.startElement(uri, localName, qName, wrapper);
View Full Code Here

    super.setAttributes(atts);
    declared    = new boolean[length];
    specified     = new boolean[length];

    if (atts instanceof Attributes2) {
      Attributes2 a2 = (Attributes2) atts;

      for (int i = 0; i < length; i++) {
        declared[i]     = a2.isDeclared(i);
        specified[i]     = a2.isSpecified(i);
      } // end for
    } // end if
    else {
      for (int i = 0; i < length; i++) {
        declared[i]     = !"CDATA".equals(atts.getType(i));
View Full Code Here

TOP

Related Classes of org.xml.sax.ext.Attributes2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.