Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: nested search nested searchTo: NULL Date: 12/5/2004 11:57:00 AM Hello everybody,
I have the following xml structure:
================| code |==================
<VCS>
<PATTERN id="chapter1" name="chapter one">
text, child elements,etcetera
</PATTERN>
<PATTERN id="chapter2" name="chapter two">
text, child elements,etcetera
</PATTERN>
<KEYWORDS>
<ITEM name="schema"/>
<ITEM name="menu bar"/>
<ITEM name="dedicated"/
</KEYWORDS>
</VCS>
================| end code |==================
VCS is the rootnode. The root contains 'PATTERNS' and 'KEYWORDS'. Patterns
can be seen as chapters that contain content. Keywords contains a list of
keywords that can exist in the patterns. I'm trying to build an XSL file
that searches for each ITEM (each keyword) if it exists in a particular
PATTERN, and then outputs a link to that pattern. I want it to output
something (html) like this:
================| code |==================
<table>
[outerloop (for each item, 1x in this example)]
<tr>
<td>item:</td>
<td> schema</td>
</tr>
<tr>
<td>exists in:</td>
<td><td>
</tr>
[innerloop (each pattern that the keyword has been found in, 2x in this
example)]
<tr>
<td>pattern: </td>
<td><a href="id of the pattern">name of the pattern</a></td>
</tr>
<tr>
<td>pattern: </td>
<td><a href="id of the pattern">name of the pattern</a></td>
</tr>
[end innerloop]
[end outerloop]
================| end code |==================
So far, I've came up with this xsl:
================| code |==================
<xsl:template match="KEYWORDS">
<table>
<xsl:for-each select="ITEM">
<tr>
<td>item:</td>
<td><xsl:value-of select="@name"/></td>
</tr>
<tr>
<td>exists in:</td>
<td><td>
</tr>
<xsl:apply-templates select="../../PATTERN" mode="keywords"/>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="PATTERN" mode="keywords">
<xsl:if test="contains(., @name)">
<tr>
<td>exists in:</td>
<td>
<a href="{@id}"><xsl:value-of select="@name"/></a>
</td>
</tr>
</xsl:if>
</xsl:template>
================| end code |==================
I've got this running when I using a static string instead of @name
attribute in the test statement ('schema' for instance') The problem is that
I don't know how I can use the @name attribute of an ITEM in the <xsl: if
test....>?
How can I do this? Or is there a better way to accomplish when I'm trying to
do. Your help is greatly appreciated.
Kind regards,
Tim
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
