Olabusayo Kilo created DAFFODIL-2946:
----------------------------------------

             Summary: Xerces Validation not working for element in 
HiddenGroupRef
                 Key: DAFFODIL-2946
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2946
             Project: Daffodil
          Issue Type: Bug
          Components: Back End
    Affects Versions: 3.9.0
            Reporter: Olabusayo Kilo


When you have a schema defined with a group referenced with elements that have 
facet restrictions, Xerces (validation = on) accurately validates the elements 
[ex1]. However if that group is referenced as a hidden group ref, Xerces no 
longer validates the elements in the hidden group [ex2].

ex1
{code:xml}
<tdml:defineSchema name="s2" elementFormDefault="unqualified">

    <xs:include 
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
    <dfdl:format ref="ex:GeneralFormat" lengthUnits="bits" 
encoding="X-DFDL-HEX-LSBF"
        byteOrder="littleEndian" bitOrder="leastSignificantBitFirst" 
alignment="1" alignmentUnits="bits"/>

    <xs:group name="group1">
      <xs:sequence>
        <xs:element name="o4" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"/>
        <xs:element name="o3" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"/>
        <xs:element name="o2" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"/>
        <xs:element name="o1" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"/>
      </xs:sequence>
    </xs:group>

    <xs:simpleType name="string1">
      <xs:restriction base="xs:string">
        <xs:length value="1"/>
      </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="valid_0_through_9">
      <xs:restriction base="ex:string1">
        <xs:enumeration value="0"/>
        <xs:enumeration value="1"/>
        <xs:enumeration value="2"/>
        <xs:enumeration value="3"/>
        <xs:enumeration value="4"/>
        <xs:enumeration value="5"/>
        <xs:enumeration value="6"/>
        <xs:enumeration value="7"/>
        <xs:enumeration value="8"/>
        <xs:enumeration value="9"/>
        <!-- NOTE that 10-15 is illegal, so we use the facet above to represent 
that
        while they are well-formed, they are invalid -->
      </xs:restriction>
    </xs:simpleType>

    <xs:element name="r">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="e1">
            <xs:complexType>
              <xs:group ref="ex:group1"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="e2">
            <xs:complexType>
              <xs:group ref="ex:group1"/>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </tdml:defineSchema>

 <tdml:parserTestCase name="test2"  model="s2">

    <tdml:document bitOrder="LSBFirst">
      <!-- 
_______________________________________________________________________ 1     2 
    3     4    -->
      <tdml:documentPart type="bits" bitOrder="LSBFirst" 
byteOrder="RTL"><![CDATA[ 0001 0010 0011 0100 ]]></tdml:documentPart>
      <!-- 
_______________________________________________________________________ invalid 
= anything above 9 -->
      <tdml:documentPart type="bits" bitOrder="LSBFirst" 
byteOrder="RTL"><![CDATA[ 1010 1001 0101 1111 ]]></tdml:documentPart>
    </tdml:document>

    <tdml:infoset>
      <tdml:dfdlInfoset>
        <ex:r>
          <e1>
            <o4>4</o4>
            <o3>3</o3>
            <o2>2</o2>
            <o1>1</o1>
          </e1>
          <e2>
            <o4>F</o4>
            <o3>5</o3>
            <o2>9</o2>
            <o1>A</o1>
          </e2>
        </ex:r>
      </tdml:dfdlInfoset>
    </tdml:infoset>
    <tdml:validationErrors>
      <tdml:error>value 'A' of element 'o1' is not valid</tdml:error>        
      <tdml:error>value 'F' of element 'o4' is not valid</tdml:error>     
    </tdml:validationErrors>

  </tdml:parserTestCase>
{code}
ex2
{code:xml}
  <tdml:defineSchema name="s3" elementFormDefault="unqualified">

    <xs:include 
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
    <dfdl:format ref="ex:GeneralFormat" lengthUnits="bits" 
encoding="X-DFDL-HEX-LSBF"
        byteOrder="littleEndian" bitOrder="leastSignificantBitFirst" 
alignment="1" alignmentUnits="bits"/>

    <xs:group name="group1">
      <xs:sequence>
        <xs:element name="o4" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"
            dfdl:outputValueCalc="{ fn:substring(../value, 4, 1) }"/>
        <xs:element name="o3" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"
            dfdl:outputValueCalc="{ fn:substring(../value, 3, 1) }"/>
        <xs:element name="o2" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"
            dfdl:outputValueCalc="{ fn:substring(../value, 2, 1) }"/>
        <xs:element name="o1" type="ex:valid_0_through_9" dfdl:length="4" 
dfdl:lengthKind="explicit"
            dfdl:outputValueCalc="{ fn:substring(../value, 1, 1) }"/>
      </xs:sequence>
    </xs:group>

    <xs:group name="group2">
      <xs:sequence>
        <xs:sequence dfdl:hiddenGroupRef="ex:group1"/>
        <xs:element name="value" type="ex:string4" dfdl:inputValueCalc="{ 
fn:concat(../o1, ../o2, ../o3, ../o4) }"/>
      </xs:sequence>
    </xs:group>

    <xs:simpleType name="string1">
      <xs:restriction base="xs:string">
        <xs:length value="1"/>
      </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="string4">
      <xs:restriction base="xs:string">
        <xs:length value="4"/>
      </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="valid_0_through_9">
      <xs:restriction base="ex:string1">
        <xs:enumeration value="0"/>
        <xs:enumeration value="1"/>
        <xs:enumeration value="2"/>
        <xs:enumeration value="3"/>
        <xs:enumeration value="4"/>
        <xs:enumeration value="5"/>
        <xs:enumeration value="6"/>
        <xs:enumeration value="7"/>
        <xs:enumeration value="8"/>
        <xs:enumeration value="9"/>
        <!-- NOTE that 10-15 is illegal, so we use the facet above to represent 
that
        while they are well-formed, they are invalid -->
      </xs:restriction>
    </xs:simpleType>

    <xs:element name="r">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="e1">
            <xs:complexType>
              <xs:group ref="ex:group2"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="e2">
            <xs:complexType>
              <xs:group ref="ex:group2"/>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </tdml:defineSchema>


<tdml:parserTestCase name="test3"  model="s3" >

    <tdml:document bitOrder="LSBFirst">
      <!-- 
_______________________________________________________________________ 1     2 
    3     4    -->
      <tdml:documentPart type="bits" bitOrder="LSBFirst" 
byteOrder="RTL"><![CDATA[ 0001 0010 0011 0100 ]]></tdml:documentPart>
      <!-- 
_______________________________________________________________________ invalid 
= anything above 9 -->
      <tdml:documentPart type="bits" bitOrder="LSBFirst" 
byteOrder="RTL"><![CDATA[ 1010 1001 0101 1111 ]]></tdml:documentPart>
    </tdml:document>

    <tdml:infoset>
      <tdml:dfdlInfoset>
        <ex:r>
          <e1><value>1234</value></e1>
          <e2><value>A95F</value></e2>
        </ex:r>
      </tdml:dfdlInfoset>
    </tdml:infoset>
    <tdml:validationErrors><!--fails with no ValidationErrors found-->
      <tdml:error>value 'A' of element 'o1' is not valid</tdml:error>
      <tdml:error>value 'F' of element 'o4' is not valid</tdml:error>
    </tdml:validationErrors>

  </tdml:parserTestCase>
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to