XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] RE: Namespace use cases

2009/7/10 Dan Brickley <danbri@danbri.org>:
> 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/


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS