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

RE: different versions of xmlns:foo are never usable

Subject: RE: different versions of xmlns:foo are never usable together?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 14 Jul 2005 17:11:08 +0100
different versions of xml
Firstly, my advice is not to change the namespace when you move to a new
version of the schema, if the new version is backwards compatible.

Secondly, if you do change the namespace, my advice is not to write
stylesheets that try to handle both versions, but rather to have a
stylesheet that converts documents from the old namespace to the new, and
put this stylesheet in the pipeline as a preprocessing step to the one that
does the real transformation. The preprocessing is essentially:

<xsl:template match="oldns:*">
  <xsl:element name="{local-name()}" namespace="new-ns-uri">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Brendan Kehoe [mailto:brendan@xxxxxxx] 
> Sent: 14 July 2005 16:19
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  different versions of xmlns:foo are never 
> usable together?
> 
> I'm working on a project that's using XML & XSLT to do lots of munging
> of files.  I've run into an odd problem that I'm hoping isn't 
> a issue of
> who-controls-what.
> 
> For example, I've got two files with recipes in them, cake.xml and
> muffin.xml.
> 
> In cake.xml is
>    <food:recipe xmlns:food="http://who/knows/Food/1.0"> ... 
> </food:recipe>
> 
> In muffin.xml is
>    <food:recipe xmlns:food="http://who/knows/Food/1.1"> ... 
> </food:recipe>
> 
> I'd like to use both of them on a style sheet like:
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
>         xmlns:food="http://who/knows/Food/1.0">
>  <xsl:output method="text" encoding="UTF-8"/>
>  <xsl:strip-space elements="*"/>
>  <xsl:template match="food:recipe">
>   <xsl:value-of select="food:name"/>: <xsl:value-of 
> select="food:calories"/>
>  </xsl:template>
> </xsl:stylesheet>
> 
> But the xmlns:food string not being the same makes is selective over
> which it's willing to use.
> 
> I understand the basic rule that xmlns:food has to be the same to be
> honored.  However, this would seem to never allow for backwards
> compatibility.  If I want version 2.0 of the 'food' namespace 
> to accept
> everything 1.0 did, but also add stuff like 
> <food:wine-suggestions/>, is
> it possible?  My stylesheet is interested in some basic bits that're
> true of both versions.
> 
> I understand that xmlns:food's contents are irrelevant, and 
> that they're
> supposed to match.  But this would mean the moment I update my
> RecipePrinter app to a newer version which includes some 
> newer recipes,
> I have to convert or get rid of all older recipes.
> 
> Please tell me I'm missing something. :-)
> Thanks,
> B
> P.S. It'd be cool if I could do
>      xmlns:food="http://.../1.0 http://.../2.0"
> to cite a union of namespaces I can accept.  But that seems 
> to threaten
> to have lots of problems.

Current Thread

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
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.