Hi Folks,
Ordinarily we think of XML Schema as a validation language. But suppose we slightly shift our perspective about what an XML Schema is: an XML Schema isn't a description of validation rules, but rather a description of a transformation. Let's suppose we have a processor that has this perspective: the processor takes as input an XML document and transforms it to the form described by the XML Schema. For example, at the end of this message is an XML Schema which specifies lat/long values with at most 2 digits to the right of the decimal point. Given the XML Schema and this XML document:
<location>
<latitude>42.366978</latitude>
<longitude>-71.022362</longitude>
</location>
the processor outputs this document:
<location>
<latitude>42.36</latitude>
<longitude>-71.02</longitude>
</location>
Notice that the XML document has been transformed so that lat/long have two digits to the right of the decimal point.
You might reasonably argue:
1. There already exists a transformation language - XSLT - so why have another transformation language?
2. If the input XML document and the XML Schema differ widely, how would the processor transform the input XML document into the form specified by the XML Schema?
Here are my answers:
1. XML Schema is way more declarative than XSLT. Making tweaks to an XML Schema doesn't require programming expertise; changes are quick and inexpensive; this is very appealing to the people that I work with. Making tweaks to an XSLT program requires substantial programming expertise and lots of regression testing; changes are slow and expensive; this is very unappealing to the people that I work with.
2. I think that the kinds of transformations that the processor could do would be limited to things such as reducing precision, fuzzing values, replacing values, appending, substring. That would be sufficient for many applications.
Question: I'm sure that I'm not the only one to have this idea. Have you had this idea of using XML Schema as a transformation language? If yes, have you fleshed out the idea? Perhaps created a processor? Got lessons learned that you can share?
/Roger
<element name="location">
<complexType>
<sequence>
<element name="latitude">
<simpleType>
<restriction base="decimal">
<fractionDigits value="2" />
</restriction>
</simpleType>
</element>
<element name="longitude">
<simpleType>
<restriction base="decimal">
<fractionDigits value="2" />
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
</element>
_______________________________________________________________________
XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.
[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php