Subject: Re: [xsl] "xmlns" problem for transform From: Chenzhou Cui <ccz@xxxxxxxxx> Date: Fri, 05 Aug 2005 06:04:11 +0800 |
----------------------- <xsl:template match="/"> <xsl:for-each select="/*"> <xsl:choose> <xsl:when test="namespace-uri()"> <xsl:call-template name="withschema"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="noschema"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> --------------
xx:node-set() is the conventional way we describe a set of functions provided by different vendors of XSLT 1.0 processors: msxml:node-set() for MSXML, xalan:node-set() for Xalan, saxon:node-set() for Saxon, oracle:node-set() for Oracle, etc. (Sometimes without the hyphen). Choose the one that suits your processor. In XSLT 2.0, you don't need the function: instead of
<xsl:apply-templates select="xx:node-set($output-of-phase-1)"/>
do
<xsl:apply-templates select="$output-of-phase-1" />
Sorry if I sometimes abbreviate my answers too much, you never know how much knowledge the person asking the question already has, or how good they are at looking it up if they don't know.
Michael Kay http://www.saxonica.com/
-----Original Message-----
From: Chenzhou Cui [mailto:ccz@xxxxxxxxx] Sent: 04 August 2005 20:34
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] "xmlns" problem for transform
Dear Michael,
I can't "xx:node-set" function from both XPath 1 and XPath 2. Problem is still there.
cheers,
Michael Kay wrote:
need themThen, how can I merge the template with my main template? I
to the correctworking as one program.Think pipelines. First stage (optional): convert everything
namespace. Second stage: do the real processing.stylesheet or with a
You can implement a pipeline either within a single
series of stylesheets linked at application level. In thefirst approach,
you typically do:prefix, the
<xsl:variable name="output-of-phase-1"> <xsl:apply-templates select="/" mode="phase-1"/> </xsl:variable>
<xsl:variable name="output-of-phase-2"> <xsl:apply-templates select="xx:node-set($output-of-phase-1)" mode="phase-2"/> </xsl:variable>
<xsl:template match="/"> <xsl:copy-of select="$output-of-phase-N"/> </xsl:template>
Michael Kay http://www.saxonica.com/
cheers, Chenzhou
Michael Kay wrote:
It's nothing to do with the presence or absence of a schema,it's all to do
same vocabulary ofwith 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
local names is used in more than one namespace. But if youdo (as RSS users
do) the best way is to write your transformation on theassumption that the
names are in a namespace, and then write a preprocessingtransformation
where necessary to put them in that namespace. This isessentially 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
define in yourfilter 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.
The schema sets the default namespace to "http://www.ivoa.net/xml/VOTable/v1.1", you need to
expression orxslt a namespace with this uri and a chosen prefix (I know 'xmlns="http://www.ivoa.net/xml/VOTable/v1.1"' is alreadypresent; you
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
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 ============================================================
-- ============================================================ 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] Extract attribute from ma, John |
[xsl] Scope of side effects in exte, Colin Paul Adams | Date | Re: [xsl] Measure the length of an , Mukul Gandhi |
Month |