xsl-list
[Top] [All Lists]

RE: different versions of xmlns:foo are never usable together?

2005-07-14 09:11:08
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(_at_)zen(_dot_)org] 
Sent: 14 July 2005 16:19
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>