<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <br>
    <blockquote cite="mid:4E42B30D.1040401@tuis.net" type="cite"> 2. The
      'unusual' condition where an attribute is in a namespace, and the
      namespace is available with a prefix, but the SAX Parser(Xerces)
      does not set that prefix on the qName (maybe an xerces bug?)<br>
      3. The even more unusual condition where an attribute is in a
      namespace, but there is no declared version of that namespace with
      a prefix, and SAXParser has an unqualified qName<br>
      <br>
      <br>
      <br>
      <h1>Situation 2</h1>
      <br>
      The second and third examples both rely on there being a 'default'
      or 'fixed' attribute of form="qualified" declared on an XML
      Schema. For example with the XMLSchema:<br>
      <br>
      <pre wrap=""><?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns=<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="http://www.jdom.org/tests/default">"myns"</a>
        xmlns:xs=<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> targetNamespace=<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="http://www.jdom.org/tests/default">"myns"</a>
        elementFormDefault="qualified">
  <xs:element name="doc">
    <xs:complexType>
      <font color="#330033"><b><xs:attribute name="att" default="defval" form="qualified"/></b></font>
    </xs:complexType>
  </xs:element>
</xs:schema></pre>
      <br>
      With the above schema, here are two representative documents. The
      first document is a representation of situation 2, where the SAX
      parser 'should' know the prefix for the attribute:<br>
      <br>
      <ns:doc xmlns:ns="myns"<br>
                     xmlns:xsi=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a><br>
                     xsi:schemaLocation=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.jdom.org/tests/default./SAXTestComplexMain.xsd">"myns

        ./MySchema.xsd"</a>><br>
      <br>
      <br>
      This should be parsed by the SAXParser, and it should add in the
      'default' attribute 'att' as part of the startElement() call. The
      resulting 'parsed' document 'should' look like:<br>
      <br>
      <ns:doc <font color="#33cc00"><b>ns:att="defval"</b></font><br>
                     xmlns:ns="myns"<br>
                     xmlns:xsi=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a><br>
                     xsi:schemaLocation=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.jdom.org/tests/default./SAXTestComplexMain.xsd">"myns

        ./MySchema.xsd"</a>><br>
      <br>
      <br>
      But, using xerces, the SAXParser is giving the 'co-ordinates' of
      the 'att' attribute as   localname=att    qName=att   
      value=defval    URI=myns<br>
      <br>
      This is situation 2, where it would 'make sense' for the parser to
      specify the qName as 'ns:att' instead of just 'att'.<br>
    </blockquote>
    This is what XSD 1.1 has to say about the attribute that is added to
    the InfoSet (Part 1, section 3.4.5.1):<br>
    <br>
    <quote><br>
    [prefix]<br>
    If the {attribute declaration} has a ·non-absent· {target namespace}
    N, then a namespace prefix bound to N in the [in-scope namespaces]
    property of the element information item in the
    ·post-schema-validation infoset·. If the {attribute declaration}'s
    {target namespace} is ·absent·, then ·absent·. <br>
    If more than one prefix is bound to N in the [in-scope namespaces],
    it is ·implementation-dependent· which of those prefixes is used.<br>
    </quote><br>
    <br>
    In this case the attribute declaration has a target namespace, and
    the namespace prefix bound to N in the instance is "ns", so this
    prefix should be used in the InfoSet and should be reflected in the
    SAX events passed to the ContentHandler. I think this Xerces
    behaviour is incorrect.<br>
    <blockquote cite="mid:4E42B30D.1040401@tuis.net" type="cite"> <br>
      <h1>Situation 3</h1>
      <br>
      Situation 3 is like situation 2, but gives the SAXParser less
      information to go on. This situation uses the exact same XMLSchema
      as situation2, only it does not declare a 'prefixed' namespace,
      just a 'default' namespace.<br>
      <br>
      <doc xmlns="myns"<br>
                     xmlns:xsi=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a><br>
                     xsi:schemaLocation=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.jdom.org/tests/default./SAXTestComplexMain.xsd">"myns

        ./MySchema.xsd"</a>><br>
      <br>
      In this case, we expect the default attribute 'att' to be added to
      the schema, but in the 'myns' namespace. Unfortunately there is
      *NO* declaration for that namespace which is 'prefixed'.<br>
      <br>
      The following is the *wrong* result (att attribute should be in
      'myns' namespace!):<br>
      <br>
      <doc <font color="#cc0000"><b>att="defval"</b></font><br>
                     xmlns="myns"<br>
                     xmlns:xsi=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a><br>
                     xsi:schemaLocation=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.jdom.org/tests/default./SAXTestComplexMain.xsd">"myns

        ./MySchema.xsd"</a>><br>
      <br>
      The real question is 'What is the correct result'....? Is the
      following 'correct' ?<br>
      <br>
      <doc <font color="#cc0000"><b>attns0:att="defval"
          xmlns:attns0="myns"</b></font> <br>
                     xmlns="myns"<br>
                     xmlns:xsi=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a><br>
                     xsi:schemaLocation=<a moz-do-not-send="true"
        class="moz-txt-link-rfc2396E"
        href="http://www.jdom.org/tests/default./SAXTestComplexMain.xsd">"myns

        ./MySchema.xsd"</a>><br>
      <br>
      <br>
      <br>
    </blockquote>
    Yes, I think the latter is correct, but the XSD 1.1 spec is not
    clear about this case. I will raise a bug. I think the answer is
    that in the Infoset produced by the schema processor, an
    implementation-defined prefix should be used; allocation of a prefix
    should be job of the schema processor, not the consumer of the
    Infoset.<br>
    <br>
    Unfortunately the Infoset spec is rather weak on defining
    constraints. XDM is clearer: see
    <a class="moz-txt-link-freetext" href="http://www.w3.org/TR/xpath-datamodel/">http://www.w3.org/TR/xpath-datamodel/</a> section 6.3.1 which states "in
    the node-name of an attribute node, if a namespace URI is present
    then a prefix must also be present". A consumer of the data model is
    entitled to expect these constraints to be satisfied.<br>
    <br>
    I have raised an XSD 1.1 bug:
    <a class="moz-txt-link-freetext" href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13750">http://www.w3.org/Bugs/Public/show_bug.cgi?id=13750</a><br>
    <br>
    Michael Kay<br>
    <br>
  </body>
</html>