xmlet / XsdParser

A Parser that parses a XSD file into a Java Structure.
MIT License
80 stars 34 forks source link

Some advice needed on xs:appInfo #38

Closed vortex314 closed 2 years ago

vortex314 commented 2 years ago

I have the following xsd fragment

                    <xs:element name="F20" type="F20_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="20"/>
                                <info:LogicalType value="TRN"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Sender's Reference</xs:documentation>
                        </xs:annotation>
                    </xs:element>

So I added the appInfo extension via an import

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:info="urn:swift:xsd:appInfo" xmlns="urn:swift:xsd:fin.103.2021" targetNamespace="urn:swift:xsd:fin.103.2021" elementFormDefault="qualified">
    <xs:import schemaLocation="appInfo.xsd" namespace="urn:swift:xsd:appInfo" />

Where appInfo.xsd contains these extensions.

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:swift:xsd:appInfo" targetNamespace="urn:swift:xsd:appInfo">
    <xs:complexType name="LogicalType">
        <xs:attribute name="value" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="Tag">
        <xs:attribute name="value" type="xs:string"/>
    </xs:complexType>
</xs:schema>

However when I parse the XSD I got in the xsdAppInfo image with this ( scala ) code

    Option(xsdElement.getAnnotation).foreach(xsdAnnotation =>
      Option(xsdAnnotation.getAppInfoList).foreach(xsdAppinfo=>
        println(xsdAppinfo)))

Question : should the xsdAppInfo contain the embedded elements and types ? Or does the XsdParser stop at this level ? Hope you can help. Your software has become very useful for us.

lcduarte commented 2 years ago

Hello, first of all glad to know the library has been useful!

The parser indeed stops at this level. In the xsd schema it states that either xsd:appInfo and xsd:documentation can have texts contents mixed with elements but we don't parse any further, we just read the element content directly into the content field.