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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.