XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Al SmithSubject: check element contents against known list
Author: Al Smith
Date: 08 Dec 2008 09:21 PM
Hi, need an xml guru's help....
Am trying to write an xsl stylesheet that will take a dynamically created xml file and output a list of free workstations.
The xml file has the following structure,

<logged in>
<software>
<userid>#*$!</userid>
<ip>172.xx.xx.xx</ip>
</software>
<software>
...
</software>
</loggedin>

The xml file outputs anything between 1 and 30 odd <software> nodes every three minutes with individual static ip addresses dependent on whether the workstation at that ip has had recent activity.

I want to query this xml file and check against a known list of ip addresses with the xsl file and output a new html list of ip's that represent free workstations.

I have managed to sort of do this by writing the following

<xsl: if test="not(contains(ip,'172.AA.AA.AAA'))">workstation A free</xsl: if>

except it runs down the entire <loggedin> list and checks each ip and outputs the text,

so if there were 9 <software> nodes, it writes "workstation A free" 9 times....

I need to write something that checks the <loggedin> tree and queries

...if within this list there is no instance of ip 'x' output this text 'yyy'

and repeats this query for all of the known workstations ip's so I get a single list of free stations.

Any ideas?
Thanks.

Postnext
(Deleted User) Subject: check element contents against known list
Author: (Deleted User)
Date: 09 Dec 2008 03:05 AM
Hi Al,
you can use a key to quickly find out if an address is in the list:

<xsl:stylesheet ...
<xsl:key match="/loggedin/software/ip" use="text()" name="list"/>

<xsl:template ...
<xsl:if test="string-length(key('list','172.AA.AA.AAA'))=0">free</xsl:if>

Alberto

Posttop
Al SmithSubject: check element contents against known list
Author: Al Smith
Date: 09 Dec 2008 08:10 PM
brilliant.....

works perfectly. thanks heaps.

al

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.