XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 30th, 2004, 01:17 PM
lancia12 lancia12 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 lancia12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old October 1st, 2004, 09:44 AM
lancia12 lancia12 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 lancia12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Need help with XSL syntax


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT