Next in thread → Next in month →

Re: [xml-dev] Foreign attributes in XML Schemas – a stroke of pure genius!

From
Ghislain Fourny <>
To
"Costello, Roger L." <>
Date
2016-06-14T12:47:50Z
ID
<CAPa8FbSOBmPY=btgcdVjA2U8+XarftTK01x5U6wGym=>
Thread
Re: [xml-dev] Foreign attributes in XML Schemas – a stroke of pure genius!
Hi Roger,

These attributes are not necessarily ignored by schema validators if you consider that an XML Schema is also an XML document.

If you add an xsi:schemaLocation attribute to your XML Schema file and drop the schemas defining your foreign attributes in there, the validator (the one used to validate your schema against the schema schema) will check that attributes declared in these schemas are valid.

Kind regards,
Ghislain


On Mon, Jun 13, 2016 at 8:05 PM, Costello, Roger L. <[email protected]> wrote:

Hi Folks,

When you create an XML Schema you can add any number of non-XML-Schema attributes onto each item in the schema.

These non-xml-schema attributes are called foreign attributes. They are ignored by XML Schema validators. (However, they can be effectively used by other applications.)

Here is an example of an XML Schema that has foreign attributes:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                     xmlns:foo="http://www.example.org"
                     elementFormDefault="qualified">
   
<xs:element name="Book" foo:binding="hardcover">
       
<xs:complexType>
           
<xs:sequence foo:order="strict">
               
<xs:element name="Title" type="xs:string" />
               
<xs:element name="Author" type="xs:string" />
           
</xs:sequence>
       
</xs:complexType>
   
</xs:element>
</xs:schema>

That schema has a foreign attribute, foo:binding, on <xs:element> and a foreign attribute, foo:order, on <xs:sequence>.

The creators of XML Schema had remarkable foresight!

How did the creators of XML Schema know that people would utilize foreign attributes to create entirely new, unforeseen technologies?

Data Format Description Language (DFDL) is a technology that is entirely based on the use of foreign attributes. Here is a portion of a “DFDL Schema”:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                     xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
                     elementFormDefault="qualified">
   
<xs:element name="PNG">
       
<xs:complexType>
           
<xs:sequence>
               
<xs:sequence dfdl:hiddenGroupRef="hiddenFile_SignatureGroup" />
                
<xs:element name="Chunk" maxOccurs="unbounded" dfdl:occursCountKind="implicit">
                   
<xs:complexType>
                       
<xs:choice>
                           
<xs:element ref="IHDR" />
                           
<xs:element ref="IDAT" />
                           
<xs:element ref="IEND" />
                            …

                       
</xs:choice>
                   
</xs:complexType>
               
</xs:element>
           
</xs:sequence>
       
</xs:complexType>
   
</xs:element>
    …

</xs:schema>

Notice the use of the dfdl:hiddenGroupRef and dfdl:occursCountKind foreign attributes.

In case you’re interested, DFDL is a technology for parsing any data format, text or binary. The output of the parser is XML. It’s pretty cool.

/Roger

 

 

 

 


Next in thread → Next in month →