[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Test for node name and attribute value
Subject: RE: [xsl] Test for node name and attribute value From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx> Date: Tue, 30 Nov 2004 14:58:30 +0100 |
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: [xsl] 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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Test for node name and at, David Carlisle | Thread | RE: [xsl] Test for node name and at, Michael Kay |
[xsl] Can't match node without node, Robert Soesemann | Date | Re: [xsl] RE: Will this work?, Geert Josten |
Month |