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
Bernd SchloemerSubject: xslt variable problem or alternative
Author: Bernd Schloemer
Date: 03 Nov 2005 03:45 AM
Hi,

I have to generate an xml out of this xml

Input
------
..
<POS><hipos>A<headerdata>..
<POS><lowpos>1<lowdata>..
<POS><lowpos>2<lowdata>..
<POS><hipos>B<headerdata>..
<POS><lowpos>1<lowdata>..
..

Output
------
..
<POS><headerdata>A<lowdata>1
<POS><headerdata>A<lowdata>2
<POS><headerdata>B<lowdata>1
..

As you can see I have to add the information from the Hipos to the associated lowpos. I tried several things
in xslt with variable and template but could not find a solution for this.

Any idea how so solve this problem ?

Regards Bernd

Postnext
Ivan PedruzziSubject: xslt variable problem or alternative
Author: Ivan Pedruzzi
Date: 03 Nov 2005 11:23 AM

Please post a samll but complete well formed documen and desired result.

Ivan Pedruzzi
Stylus Studio Team

Postnext
Bernd SchloemerSubject: xslt variable problem or alternative
Author: Bernd Schloemer
Date: 03 Nov 2005 11:37 AM

input
<data>
<pos>
<matnr>4711</matnr>
<posnr>1</posnr>
<hipos>1</hipos>
<info>this is hiposition A</info>
</pos>
<pos>
<charge>A1</charge>
<posnr>1</posnr>
<subpos></subpos>
<info>this is a subposition nr 1 from hipos 1</info>
</pos>
<pos>
<charge>A2</charge>
<posnr>3</posnr>
<subpos></subpos>
<info>this is a subposition nr 2 from hipos 1</info>
</pos>
<pos>
<matnr>4712</matnr>
<posnr>4</posnr>
<hipos>1</hipos>
<info>this is hiposition B</info>
</pos>
<pos>
<charge>B1</charge>
<posnr>3</posnr>
<subpos></subpos>
<info>this is a subposition nr 1 from hipos B</info>
</pos>
</data>

result
<data>
<pos>
<charge>A1</charge>
<matnr>4711</posnr>
</pos>
<pos>
<charge>A2</charge>
<matnr>4711</posnr>
</pos>
<pos>
<charge>B1</charge>
<matnr>4711</posnr>
</pos>
</data>

Posttop
Ivan PedruzziSubject: xslt variable problem or alternative
Author: Ivan Pedruzzi
Date: 03 Nov 2005 12:02 PM
Given the data without knowing the semantic this is one of the possible interpretation


<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<data>
<xsl:for-each select="data/pos[subpos and string-length(subpos) = 0 ]">
<pos>
<charge>
<xsl:value-of select="charge"/>
</charge>
<matnr>
<xsl:value-of select="preceding-sibling::pos[not(subpos)][1]/matnr"/>
</matnr>
</pos>
</xsl:for-each>
</data>
</xsl:template>
</xsl:stylesheet>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

   
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.