OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng message

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


Subject: Re: Use of QNames


I think I have burnt most of my arguments, especially if you don't
answer my points about the architecture...

However, can I submit a (last?) use case ?

James Clark wrote:
> 
> Eric van der Vlist wrote:
> 
> > > - XPath/XSLT (namespace axis provides *exactly* this information)
> >
> > The namespace axis is very weak compared to the other axis (you can't
> > apply templates on it and you can't easily replace a prefix by another
> > one) and it would be much easier to manipulate the syntax I have
> > proposed than a syntax based on namespaces declarations.
> 
> I disagree: in some ways it's easier using namespace declarations than
> using a new syntax, because if you use namespace declarations XSLT/XPath
> handles inheritance for you, and automatically ensures that the
> appropriate namespace declarations are copied over and generated as
> necessary.

Taking back the example:

<?xml version="1.0" encoding="UTF-8"?>
<element name="e:addressBook" xmlns:e="http://www.example.com">
 <zeroOrMore>
  <element name="e:card">
   <element name="e:name">
    <anyString/>
   </element>
   <element name="e:email">
    <anyString/>
   </element>
  </element>
 </zeroOrMore>
</element>

Can you show me how we can write a generic transformation that would
produce 

<?xml version="1.0" encoding="UTF-8"?>
<element name="e:addressBook" xmlns:e="http://www.example.com/v2">
 <zeroOrMore>
  <element name="e:card">
   <element name="e:name">
    <anyString/>
   </element>
   <element name="e:email">
    <anyString/>
   </element>
  </element>
 </zeroOrMore>
</element>

(or equivalent) to adapt the TREX schema to a modification of the
namespace of my vocabulary to prepare a next version ?

The transformation should, of course, handle namespace declaration that
can be done on any element.

I have given it a naive try:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:param name="old" select="'http://www.example.com'"/>
 <xsl:param name="new" select="'http://www.example.com/v2'"/>

 <xsl:template match="*">
  <xsl:element name="{name()}">
   <xsl:apply-templates select="node()|@*"/>
   <xsl:for-each select="namespace::*[.=$old]">
	????
   </xsl:for-each>
  </xsl:element>
 </xsl:template>

 <xsl:template match="@*">
  <xsl:copy-of select="."/>
 </xsl:template>
</xsl:stylesheet>

but I am blocked at the question marks since I cannot create a namespace
node with the old prefix and the new URI.

I could do it if there was an element or attribute to create as a
literal with this namespace, but it's not the case here.

The only solution that seems to be left is to define a new namespace
prefix (for instance in the top level element if I accept to write it as
a literal and/or to add a dummy attribute somewhere that would be using
it) and to analyze all the attributes that can hold a namespace prefix
to change their prefix when needed.

Doesn't look straightforward to handle the general case where the prefix
may be redefine in each element and a URI have multiple prefixes !

I may of course have missed something since I am not using the namespace
axis that much ;=) ...

Eric

> James

-- 
See you in Austin (Knowledge Technologies 2001)
              http://www.gca.org/attend/2001_conferences/kt_2001/mon.htm
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------


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


Powered by eList eXpress LLC