xmlHelpline Blog
Xml, Xslt, data standards, and anything else...









Using multiple file inputs with Schema Lightener

Users have asked me to support multiple xml instances files with the Schema Lightener.  Because it is not knowable how many is the proper amount to support, here is a much simpler way to obtain this functionality.

Simply wrap as many xml instances as you want in a dummy root tag.  Then use it as a single xml instance with the Lightener.

Here is an example I've used to illustrate this:
(Note: Some of the SWIFT standards folks in particular have requested this functionality.  Please test it and let me know if this works for you.)

<ns1:dummy xmlns:ns1="dummy-ns-omit-from-result">

<!-- Flattener takes root element "ns1:dummy" as input just like any other element,
but since it does not occur in the schema, it never appears in the result.

Below is the first xml instance pasted in.  -->

    <ns6:SyncItemMaster xmlns:ns6="http://www.openapplications.org/oagis/9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.openapplications.org/oagis/9   SyncItemMaster.xsd"
        releaseID="releaseID0">
        <ns6:ApplicationArea>
            <ns6:CreationDateTime>2006-05-04</ns6:CreationDateTime>
        </ns6:ApplicationArea>
        <ns6:DataArea>
            <ns6:Sync>

                <!-- Element "ns6:ActionCriteria" is not in the second instance, but *will* occur in result. -->
                <ns6:ActionCriteria/>

            </ns6:Sync>
            <ns6:ItemMaster> </ns6:ItemMaster>

            <ns6:ItemMaster> </ns6:ItemMaster>
        </ns6:DataArea>
    </ns6:SyncItemMaster>

    <!-- Below is the second xml instance pasted in. -->

    <ns6:SyncItemMaster xmlns:ns6="http://www.openapplications.org/oagis/9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.openapplications.org/oagis/9   SyncItemMaster.xsd"
        releaseID="releaseID0">
        <ns6:ApplicationArea>
            <ns6:CreationDateTime>2006-05-04</ns6:CreationDateTime>
        </ns6:ApplicationArea>
        <ns6:DataArea>
            <ns6:Sync> </ns6:Sync>
            <ns6:ItemMaster>

                <!-- Element "ns6:ItemLocation" is not in the first instance, but *will* occur in result. -->
                <ns6:ItemLocation/>

            </ns6:ItemMaster>
            <ns6:ItemMaster> </ns6:ItemMaster>
        </ns6:DataArea>
    </ns6:SyncItemMaster>

</ns1:dummy>
© Copyright Paul Kiel.

Older posts