Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6362115

child/attribute axes should be accepted in keys {field}

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • 6
    • xml

      In XML Schema specification there is requirement that ONE of the following should be true:
      ------ Spec excerpt (http://www.w3.org/TR/xmlschema-1/#c-fields-xpaths)
      2.1
         Selector XPath expressions
         [1] Selector ::= Path ( '|' Path )*
         [2] Path ::= ('.//')? Step ( '/' Step )*
         [3] Step ::= '.' | NameTest
         [4] NameTest ::= QName | '*' | NCName ':' '*'

         Path in Field XPath expressions
         [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )
         [5] token ::= '.' | '/' | '//' | '|' | '@' | NameTest
         [6] whitespace ::= S
         [7] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )

      2.2 It must be an XPath expression involving the child and/or attribute axes whose abbreviated form is as given above.

      ----- End spec

      But SchemaFactory reports error on schema containing XPath expression with "child" axis.

      For example, for this schema (Test: xml_schema/msxsdtest/identityConstraint/idL029.html#idL029):
      <?xml version="1.0"?>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="myNS.tempuri.org" xmlns:myNS="myNS.tempuri.org" xmlns="myNS.tempuri.org">
      <xsd:element name="root">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element ref="t" maxOccurs="unbounded"/>
      </xsd:sequence>
      </xsd:complexType>
      <xsd:key id="foo123" name="tableu">
      <xsd:selector xpath=".//myNS:t"/>
      <xsd:field xpath="child::myNS:row"/>
      </xsd:key>
      </xsd:element>
      <xsd:element name="t" type="ttype"/>
      <xsd:complexType name="ttype">
      <xsd:sequence>
      <xsd:element name="row" type="xsd:string" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="col" type="xsd:string"/>
      </xsd:complexType>
      </xsd:schema>

      Following code:
      ....
      public static void main(String[] args) {
      try {
      SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Schema s = sf.newSchema(new File("idL029.xsd"));
      } catch (SAXException e) {
      e.printStackTrace();
      }
      }
      ....

      Reports error:

      org.xml.sax.SAXParseException: c-general-xpath: The expression 'child::myNS:row' is not valid with respect to the XPath subset supported by XML Schema.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
      ....

            rmandavasunw Ramesh Mandava (Inactive)
            vsosninsunw Vladimir Sosnin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: