Subject: RE: [xsl] Test for node name and attribute value From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 30 Nov 2004 14:55:44 -0000 |
Still no source document, but if I apply this to the source document <my-relation/> I get <?xml version="1.0" encoding="UTF-8"?><FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO/><my-relation/> and if I change the template rule to say match="my-relation" I get exactly the same output. Perhaps my-relation in your source document is actually an attribute rather than an element? Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Robert Soesemann [mailto:rsoesemann@xxxxxxxxxxx] > Sent: 30 November 2004 13:59 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] 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: [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, Robert Soesemann | Thread | [xsl] Find ancestor attribute of va, Robert Soesemann |
RE: [xsl] Can't match node without , Robert Soesemann | Date | Re: [xsl] grouping date ranges with, David Carlisle |
Month |