Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] RE: Namespace use cases

From: Andrew Welch <andrew.j.welch@-----.--->
To: Dan Brickley <danbri@------.--->
Date: 7/10/2009 9:21:00 AM
2009/7/10 Dan Brickley <danbri@d...>:
> On 10/7/09 10:23, Michael Kay wrote:
>>>
>>> I would love to hear of some success or horror stories of
>>> multi-namespaces in authoring content.
>>
>> A very simple success story is that it proved very easy to allow XML
>> Schemas
>> to be embedded in XSLT stylesheets, despite the fact that the vocabularies
>> were developed independently (without this in mind) and had overlapping
>> local names, eg. xsl:element vs xsd:element.
>
> Interesting. Can you flesh out the example --- why would someone want to do
> this?

You can embed the schema in the stylesheet, and then use the types to
check your input and/or output as its constructed.  For example:

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs">

<xsl:import-schema>
  <xs:schema>
    <xs:element name="foo">
      <xs:complexType>
      	<xs:sequence>
          <xs:element name="bar"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>	
  </xs:schema>	
</xsl:import-schema>

<xsl:template match="/" as="schema-element(foo)">
  <foo xsl:validation="strict">
    <wrong/>
  </foo>
</xsl:template>

</xsl:stylesheet>

In the above, a <foo> must contain a <bar>, but I'm generating
<foo>/<wrong>, so at runtime I get the message:

"Element wrong is not permitted in the content model of the complex
type of element foo; ... Line#: 18; Column#: 50"

This is better than just validating the result as it tells me where in
the XSLT I generated the invalid output.

Its nice to embed a small XSD for a few custom types, but as soon at
its gets to any size then it needs to be a separate file.


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

_______________________________________________________________________

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@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent