[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: Namespace use cases

  • From: Andrew Welch <andrew.j.welch@gmail.com>
  • To: Dan Brickley <danbri@danbri.org>
  • Date: Fri, 10 Jul 2009 10:20:15 +0100

Re:  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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.