|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help with XSL syntax
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! |
|
#2
|
|||
|
|||
|
What I have currently
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Need help with XSL syntax |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|