CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    97

    XSL/T and performing Filtering

    How do you filter out nodes which contain a value using a stop list? I have come across one example but I'm wondering is there any other way of doing it?
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:sw="stopWords" exclude-result-prefixes="sw">
    
    <sw:stop>
    <word>AA_IT</word>
    <word>AA_JA</word>
    <word>AA_NN</word>
    <word>AA_SP</word>
    <word>AA_SW</word>
    <word>AA_UK</word>
    <word>AA_US</word>
    </sw:stop>
    
    <xsl:variable name="stop-words" select="document('')/xsl:stylesheet/sw:stop/word"/>
    
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    
    <xsl:for-each select="DM32IMPORT/SOFT_VINE_NEW[INDEX_CODE=$stop-words]">
    
    <xsl:value-of select="DATE"/>
    <xsl:value-of select="INDEX_CODE"/>
    <xsl:value-of select="INDEX_VALUE"/>
    </xsl:if>
    </xsl:for-each>
    
    <xsl:variable name="stop-words" select="document('')/xsl:stylesheet/sw:stop/word"/>
    
    </xsl:template>
    </xsl:stylesheet>

  2. #2
    Join Date
    May 2003
    Location
    Denmark
    Posts
    1,315
    One way of dooing things not enough for you ?, XSL isn't a very flexible language, if you want many ways of dooing things, XSL is not for you.

    If the code above does not suit you for some reason, you should explain why. You cannot possible expect people to spend time working out a different method, just have you respond 'nahh that doesn't work for me either'

    There are of course possible variations to the above, personally I would prefer to move the list of words to a seperate file, and use an 'apply-templates select' rather than 'for-each select' to run the selection. And running the select directly from the root template probably wouldn't be my first choise, not very flexible if you also need other things.
    The biggest problem encountered while trying to design a system that was completely foolproof,
    was, that people tended to underestimate the ingenuity of complete fools.
    Douglas Adams

  3. #3
    Join Date
    Mar 2003
    Posts
    97
    I don't expect people do go off and work out another way of doing it, I would just like people to post an example of a method they have used.

    I totally new to XSLT and it took me forever to find an example on filtering, a post like this could help people in the future. I am just asking people is there another way to filter so that I understand XSLT better.

    Last time I checked there wasn't anything wrong with wanting to learn


    I would prefer to move the list of words to a separate file, and use an 'apply-templates select' rather than 'for-each select' to run the selection. And running the select directly from the root template probably wouldn't be my first choice, not very flexible if you also need other things.
    I have listened to your suggestions and plan to implement them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured