Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2004, 10:59 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Noob needs help with XSL syntax question

I am fairly new at XSL and XPath and this may be a noob type question but any help would be greatly appreciated. This is what I am trying to do:

I have XML that looks like this:
<?xml version="1.0" ?>
<RULES>
    <EXECUTE_PROGRAM>
        <PATHNAME>Program.exe</PATHNAME>
        <COMMAND_LINE>/D=%MSG% /I=%INST% /S=Failed</COMMAND_LINE>
    </EXECUTE_PROGRAM>
    <EXECUTE_PROGRAM>
        <PATHNAME>Program.exe</PATHNAME>
        <COMMAND_LINE>/D:%MSG% /I:%INST% /S=Active</COMMAND_LINE>
    </EXECUTE_PROGRAM>
    <EXECUTE_PROGRAM>
        <PATHNAME>Program.exe</PATHNAME>
        <COMMAND_LINE>/D:%MSG% /I:%INST% /S=Active</COMMAND_LINE>
    </EXECUTE_PROGRAM>
    <EXECUTE_PROGRAM>
        <PATHNAME>Program.exe</PATHNAME>
        <COMMAND_LINE>Another valid command line</COMMAND_LINE>
    </EXECUTE_PROGRAM>
    <EXECUTE_PROGRAM>
        <PATHNAME>Program.exe</PATHNAME>
        <FLAGS>1001001</FLAGS>
    </EXECUTE_PROGRAM>
</RULES>

I am trying to find all instances where the <COMMAND_LINE> node "contains" either '/S=Active' or '/S=Failed' or '/S=Success' when the <PATHNAME> is equal to 'Program.exe'. But here is the catch. I only want these nodes written when the '/S=Active' or '/S=Failed' or '/S=Success' shows up in the <COMMAND_LINE> more than 1 time. I also want to capture when it doesn't appear at all.

The transformed XML should look something like this:
<?xml version="1.0" ?>
<RULES>
    <EXECUTE_PROGRAM>
        <PATHNAME>Program.exe</PATHNAME>
        <COMMAND_LINE>/D:%MSG% /I:%INST% /S=Active</COMMAND_LINE>
    </EXECUTE_PROGRAM>
    <EXECUTE_PROGRAM>
        <SOME_NODE>/S=Success not found</SOME_NODE>
    </EXECUTE_PROGRAM>
</RULES>

I have been banging my head against the wall with this one and any help would be greatly appreciated. TIA!
 
Old October 1st, 2004, 08:45 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thought I would post the XSL that I currently have as well:

Code:
<xsl:for-each select=".//EXECUTE_PROGRAM">
    <xsl:variable name="cmd_line" select="COMMAND_LINE"/>
    <xsl:variable name="exe_name" select="PATHNAME"/>
    <xsl:if test="(contains($cmd_line, '/S=Active') or contains($cmd_line, '/S=Success') or contains($cmd_line, '/S=Failed')) and contains($exe_name,'WISSTAT.EXE')">
        <xsl:element name="COMMAND_LINE">
                <!-- <xsl:attribute name="GenErr">False</xsl:attribute>
                <xsl:attribute name="Msg">WARNING: Flags warning</xsl:attribute>
                <xsl:attribute name="Itm">False</xsl:attribute> -->
            <xsl:value-of select="COMMAND_LINE"/>
        </xsl:element>
    </xsl:if>
</xsl:for-each>
This is the "Positive" of what I am looking for and brings back only those lines that meet that condition. I could put a "not" in front of it but then it would still bring back valid nodes even though they have the desired string and this isn't what I am looking for either. Any help would be greatly appreciated.




Similar Threads
Thread Thread Starter Forum Replies Last Post
noob question mattl Java Basics 1 August 27th, 2007 11:28 PM
VB Noob - Little syntax help Devilmonkey VB Databases Basics 5 May 16th, 2007 05:23 PM
Noob XML question Skido XML 0 December 23rd, 2005 04:25 PM
Noob Question jverdin BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 April 2nd, 2004 10:01 AM
xsl:sort- select attribute, syntax question Flashlight XSLT 3 August 14th, 2003 12:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.