Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


nested search

From: "Tim" <tpaymans@-------.--->
To: 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 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent