Subject: RE: [xsl] Getting a predicate right From: "Jacoby, Peter R." <PJACOBY@xxxxxxxxxxxx> Date: Tue, 30 Jul 2002 15:55:39 -0400 |
Matt, > My XML Sheet looks like this: > <test> > <colors> > <desc id="0" name="blue"/> > <desc id="1" name="red"/> > <desc id="2" name="white"/> > </colors> > <mesg grp="1">Hi how are you?</mesg> > <mesg grp="0">I am fine.</mesg> > <mesg grp="2">That is good.</mesg> > </test> > In my XSL I am going through the messages and trying > to match the attribute grp from mesg with the > attribute id from desc. > something like this: > //test/colors/desc[@grp]/@name > or > //test/colors/desc[@id = @grp]/@name You're close, but since your XPath grabs a reference to a new element as the context node, you need to save off your search string before attempting to match. If the <mesg> element is the context node you can do something like this: <xsl:template match="mesg"> <xsl:variable name="grpToMatch" select="@grp" /> <xsl:value-of select="/test/colors/desc[@id=$grpToMatch]/@name" /> </xsl:template> Or you can do it the other way around (match on the desc). Hope that helps. -Peter [Two colo(u)r questions in one afternoon, at least this one was spelled correctly.] XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Getting a predicate right, Joerg Heinicke | Thread | [xsl] java extension in xsl help..p, Zoe Peng |
Re: [xsl] Getting a predicate right, Joerg Heinicke | Date | [xsl] XSchema validation, Vishal Bhasin |
Month |