|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Test for node name and attribute value
Sorry for not telling you everything.
Here is my whole xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Copy nodes except those affected by other templates -->
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Match all kiwi-relation elements -->
<xsl:template match="node()[name(.) =
'my-relation']"><FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<!-- Get expected type of related content -->
<xsl:variable name="expected-type"
select="@type"/>
<!-- For each <A> pointing to related content...
-->
<xsl:for-each select="kiwi-link">
<!-- Extract type of external
contentitem eighter from anchored fragment or document -->
<xsl:variable name="external-type">
<xsl:variable
name="external-doc" select="document(@url)"/>
<xsl:choose>
<xsl:when test="@anchor
!= ''">
<xsl:variable
name="anchor-name" select="@anchor"/>
<xsl:variable
name="anchor-node" select="$external-doc//my-anchor[@name =
$anchor-name]"/>
<xsl:value-of
select="$anchor-node/ancestor::my-contentitem[1]/@type"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//my-contentitem/@type"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--
Include my-link tag when types
match,
otherwise add my-error tag
-->
<xsl:choose>
<xsl:when test="$expected-type =
$external-type">
<kiwi-link url="{@href}"
/>
</xsl:when>
<xsl:otherwise>
<my-error>
Unable to
resolve relation to file '<xsl:value-of select="@href"/>'.
Expected type:
<xsl:value-of select="$expected-type"/> |
Found type:
<xsl:value-of select="$external-type"/>
</my-error>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Dienstag, 30. November 2004 14:51
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: Test for node name and attribute value
> Thanks for you reply.
> I don't know why but node matches don't work when I use the simple
> syntax:
>
> my-relation
>
> instead of
>
> node()[name(.)='my-relation'
>
> Is there something wron with my xsl transformer?
Given that you have been asking fairly elementary XPath questions, it
seems more likely that the error is on your side. Show us a full example
of what you are doing, and we'll tell you where it's wrong.
Michael Kay
http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








