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
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

 
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.