[
https://issues.apache.org/jira/browse/XMLSCHEMA-64?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oscar Westra van Holthe - Kind updated XMLSCHEMA-64:
----------------------------------------------------
Description:
Consider this schema:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="https://www.github.com/opwvhk/schemawalkerbug"
xmlns="https://www.github.com/opwvhk/schemawalkerbug"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="RepeatedSubElementNames">
<xs:complexType>
<xs:sequence>
<xs:element name="wrappedStringArray">
<xs:complexType>
<xs:sequence>
<xs:element name="array" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="wrappedNumber">
<xs:complexType>
<xs:sequence>
<xs:element name="array" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="number"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="string">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="number">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:int"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
{code}
When walking this schema, the 2nd {{array}} element is not traversed, resulting
in missing the subelements {{{}number{}}}.
To fix, in line 237 of {{{}XmlSchemaWalker.java{}}}, adjust the cycle detection.
was:
Consider this schema:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="https://www.github.com/opwvhk/schemawalkerbug"
xmlns="https://www.github.com/opwvhk/schemawalkerbug"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="RepeatedSubElementNames">
<xs:complexType>
<xs:sequence>
<xs:element name="wrappedStringArray">
<xs:complexType>
<xs:sequence>
<xs:element name="array" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="wrappedNumber">
<xs:complexType>
<xs:sequence>
<xs:element name="array" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="number"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="string">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="number">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:int"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
{code}
When walking this schema, the 2nd {{array}} element is not traversed, resulting
in missing the subelements {{{}number{}}}.
To fix, in line 241 of {{{}XmlSchemaWalker.java{}}}, only add elements to
{{visitedElements}} if they're top-level elements, or if their type is a
top-level type.
After all, infinite recursion is only possible using references, and only
toplevel elements/types can be referenced.
So change this:
{code:java}
if (!element.isAnonymous() && !previouslyVisited) {
visitedElements.add(element.getQName());
} {code}
Into this:
{code:java}
if (!element.isAnonymous() && !previouslyVisited && (element.isTopLevel() ||
schemaType.isTopLevel()) {
visitedElements.add(element.getQName());
} {code}
> Schema walker thinks an element was previously visited when it's not
> --------------------------------------------------------------------
>
> Key: XMLSCHEMA-64
> URL: https://issues.apache.org/jira/browse/XMLSCHEMA-64
> Project: XmlSchema
> Issue Type: Bug
> Reporter: Oscar Westra van Holthe - Kind
> Priority: Major
>
> Consider this schema:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="https://www.github.com/opwvhk/schemawalkerbug"
> xmlns="https://www.github.com/opwvhk/schemawalkerbug"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:element name="RepeatedSubElementNames">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="wrappedStringArray">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="array" minOccurs="0"
> maxOccurs="unbounded">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="wrappedNumber">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="array" minOccurs="0"
> maxOccurs="unbounded">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="number"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="string">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="xs:string"/>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
> <xs:element name="number">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="xs:int"/>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> {code}
> When walking this schema, the 2nd {{array}} element is not traversed,
> resulting in missing the subelements {{{}number{}}}.
>
> To fix, in line 237 of {{{}XmlSchemaWalker.java{}}}, adjust the cycle
> detection.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]