Altova Mailing List Archives>Archive Index >xml-dev Archive Home >Recent entries >Thread Prev - Re: [xml-dev] RE: Namespace use cases [Thread Next] Re: [xml-dev] RE: Namespace use casesTo: 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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
