Subject: Re: [xsl] "xmlns" problem for transform From: Chenzhou Cui <ccz@xxxxxxxxx> Date: Thu, 04 Aug 2005 16:30:24 +0800 |
cheers, Chenzhou
It's nothing to do with the presence or absence of a schema, it's all to do with the fact that X in namespace N is completely unrelated to X in namespace N2, or X in no namespace.
You shouldn't get yourself into this situation where the same vocabulary of local names is used in more than one namespace. But if you do (as RSS users do) the best way is to write your transformation on the assumption that the names are in a namespace, and then write a preprocessing transformation where necessary to put them in that namespace. This is essentially a variant on the identity transform:
<xsl:template match="*[namespace-uri()='']"> <xsl:element name="{local-name()}" namespace="the.real.namespace"> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template>
Michael Kay http://www.saxonica.com/
-----Original Message-----
From: Chenzhou Cui [mailto:ccz@xxxxxxxxx] Sent: 03 August 2005 21:29
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] "xmlns" problem for transform
Dear Joris:
Thank you very much! Now the problem is PARTLY solved. After I add the non-default namespace for my xslt filter and all needed prefix, the filter works well with schema assigned data files. However, it can not transform files without schema. An opposite problem to before.
How can I do?
cheers,
Joris Gillis wrote:
Hi,<ccz@xxxxxxxxx>:
Tempore 21:02:56, die 08/03/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Chenzhou Cui
namespace-related problemit can't transformAs the post's subject indicates, this is a
the body of sample file with "schema" assigned.
indeed.present; you
The schema sets the default namespace to "http://www.ivoa.net/xml/VOTable/v1.1", you need to define in your xslt a namespace with this uri and a chosen prefix (I know 'xmlns="http://www.ivoa.net/xml/VOTable/v1.1"' is already
need to add another non-default namespace declaration). e.g. 'xmlns:VOT="http://www.ivoa.net/xml/VOTable/v1.1"'
Next step is to find all element names in any xpath expression or pattern in your xslt and add the prefix.
e.g. <xsl:for-each select="//RESOURCE/TABLE/FIELD" /> becomes
<xsl:for-each select="//VOT:RESOURCE/VOT:TABLE/VOT:FIELD"/>
regards,
-- ============================================================ Chenzhou Cui (Chinese Virtual Observatory: China-VO) National Astronomical Observatory | Tel: (8610)64841695 Chinese Academy of Sciences | FAX: (8610)64878240 20A Datun Road, Chaoyang District | Email: ccz@xxxxxxxxx Beijing 100012, China | WWW: www.lamost.org/~cb ============================================================
-- ============================================================ Chenzhou Cui (Chinese Virtual Observatory: China-VO) National Astronomical Observatory | Tel: (8610)64841695 Chinese Academy of Sciences | FAX: (8610)64878240 20A Datun Road, Chaoyang District | Email: ccz@xxxxxxxxx Beijing 100012, China | WWW: www.lamost.org/~cb ============================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] "xmlns" problem for trans, Michael Kay | Thread | RE: [xsl] "xmlns" problem for trans, Michael Kay |
Re: [xsl] xsl:key function help, Nick Fitzsimons | Date | Re: [xsl] Parsing XML from a CDATA , David Carlisle |
Month |