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
Alex StarSubject: Is ther are any XSLT solutions available?
Author: Alex Star
Date: 27 Jun 2007 02:51 PM
Originally Posted: 27 Jun 2007 02:30 PM
I have next XML as input for my map:

<CPSData xmlns="http://3wworld.CPS">
<CPS xmlns="">
<CallSchedule>
<CallSchData/>
<CallSchData>2</CallSchData>
<CallSchData>1</CallSchData>
<CallSchData>2</CallSchData>
<CallSchData>5</CallSchData>
<CallSchData>02/01/2005</CallSchData>
<CallSchData>2</CallSchData>
<CallSchData>100.0000</CallSchData>
<CallSchData>5</CallSchData>
<CallSchData>02/01/2010</CallSchData>
<CallSchData>2</CallSchData>
<CallSchData>200.0000</CallSchData>
<CallSchData/>
</CallSchedule>
</CPS>
</CPSData>

I need to filter <CallSchData> and extract only the values of nodes following by the one with the value equal 5 (for <CallSchDate>) and 2(for CallSchValue). Also, I want to disregard first three nodes:
<CallSchData/>
<CallSchData>2</CallSchData>
<CallSchData>1</CallSchData>

So, the expected result should looks like this:

<CPSFinalData xmlns="http://3wworld.CPS_Final">
<CPS xmlns="">
<CallSchLoop>
<CallSchedule>
<CallSchDate>02/01/2005</CallSchDate>
<CallSchValue>100.0000</CallSchValue>
</CallSchedule>
<CallSchedule>
<CallSchDate>02/01/2010</CallSchDate>
<CallSchValue>200.0000</CallSchValue>
</CallSchedule>
</CallSchLoop>
</CPS>

</CPSFinalData>

I thoughted that I could handle it in the BizTalk map, but I guess, it is better to do using XSLT directly. The problem is - I am not that familiar with XSLT, so please help.
Thank you in advance,

Alex.

Postnext
Tony LavinioSubject: Is ther are any XSLT solutions available?
Author: Tony Lavinio
Date: 27 Jun 2007 09:38 PM
Which version of Stylus Studio are you using?

Postnext
Alex StarSubject: Is ther are any XSLT solutions available?
Author: Alex Star
Date: 28 Jun 2007 09:40 AM
I have Altova XML Spy.

Postnext
Tony LavinioSubject: Is ther are any XSLT solutions available?
Author: Tony Lavinio
Date: 28 Jun 2007 09:51 AM
This is a support forum for Stylus Studio users.
Please ask your questions on the appropriate Altova forum.

Postnext
(Deleted User) Subject: Is ther are any XSLT solutions available?
Author: (Deleted User)
Date: 28 Jun 2007 10:24 AM
</smirk>

Ian

Posttop
Alex StarSubject: Is ther are any XSLT solutions available?
Author: Alex Star
Date: 28 Jun 2007 11:19 AM
Actually, I am using Studio as well some times(latest release) and I am a registered user here(othervise, how would I be able to post a questions here).
I beleave it does not matter what tool you using - XSLT is a standard for both tools.

Thank you for the help, I have resolved this issue anyway already.
Here is how I did it:

<?xml version="1.0" encoding="utf-16" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:s0="http://3wworld.CPS"
exclude-result-prefixes="s0" >
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<ns0:CPSFinalData xmlns:ns0="http://3wworld.CPS_Final">
<xsl:if
test="/s0:CPSData/CPS/CallSchedule/CallSchData[text()='5' and
position() > 3]">
<CPS>
<CallSchLoop>
<xsl:for-each
select="/s0:CPSData/CPS/CallSchedule/CallSchData[text()='5']">
<CallSchedule>
<CallSchDate>
<xsl:value-of select="./following-sibling::CallSchData[1]/text()" />
</CallSchDate>
<CallSchValue>
<xsl:value-of
select="./following-sibling::CallSchData[1]/following-sibling::CallSchData[1]/following-sibling::CallSchData[1]/text()"
/>
</CallSchValue>
</CallSchedule>
</xsl:for-each>
</CallSchLoop>
</CPS>
</xsl:if>
</ns0:CPSFinalData>
</xsl:template>
</xsl:stylesheet>

   
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.