Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1598

SGXMLScanner omits namespace prefixes when reporting start/end element QNames

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.0
    • 2.8.0
    • None
    •  64-bit
      Solaris 10
      Sun CC: Sun C++ 5.7 Patch 117830-07 2006/03/15

    Description

      When parsing a document the SGXMLScanner and (sometimes) the IGXMLScanner does not
      correctly report QNames when calling startElement() and endElement(): specifically, it omits
      the namespace prefix. (Other scanners behave differently=>correctly.)

      For example, using the SAX2Print sample against the document:
      <doc xsi:schemaLocation="doc doc.xsd ent ent.xsd"
      xmlns="doc" xmlns:ent="ent"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <ent:company>HP</ent:company>
      </doc>

      (with appropriate "doc.xsd" and "ent.xsd" files in the CWD), "SAX2Print -s" reports:
      <?xml version="1.0" encoding="LATIN1"?>
      <doc xsi:schemaLocation="doc doc.xsd ent ent.xsd">
      <ent:company>HP</ent:company>
      </doc>

      but "SAX2Print" reports:
      <?xml version="1.0" encoding="LATIN1"?>
      <doc xsi:schemaLocation="doc doc.xsd ent ent.xsd">
      <company>HP</company>
      </doc>

      Note "<company>" vs. "<ent:company>".

      Note also that SAX2Print by default will be using the IGXMLScanner;
      if you force the use of the SGXMLScanner by modifying SAX2Print.cpp:

          • SAX2Print.cpp Fri May 26 16:18:07 2006
          • SAX2Print.cpp.ORIG Fri May 26 16:16:13 2006
            ***************
          • 319,329 ****
            parser->setFeature(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking);
            parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, namespacePrefixes);
      • parser->setProperty(
      • xercesc::XMLUni::fgXercesScannerName,
      • static_cast<void*>(const_cast<XMLCh*>(
      • xercesc::XMLUni::fgSGXMLScanner)));
        -
        //
        // Create the handler object and install it as the document and error
        // handler for the parser. Then parse the file and catch any exceptions

      then both "SAX2Print -s" and SAX2Print" fail, printing <company> rather than <ent:company>.

      I will attach the test document and schema files.

      We have a kludge for SAX2XMLReaderImpl.cpp that works around the above bug,
      but it's not the right fix, as there is nothing really wrong with SAX2XMLReaderImpl.cpp,
      just the underlying scanners. Nonetheless, I will attach that also.

      Attachments

        1. doc.xsd
          0.3 kB
          Michael Fuller
        2. ent.xsd
          0.2 kB
          Michael Fuller
        3. SAX2XMLReaderImpl.diff
          4 kB
          Michael Fuller
        4. test.xml
          0.2 kB
          Michael Fuller

        Activity

          People

            Unassigned Unassigned
            msf Michael Fuller
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: