[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Making flat files strucutred hierarchically

Subject: Re: Making flat files strucutred hierarchically
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Wed, 6 Oct 2004 08:27:52 -0700 (PDT)
xml versio
Hi Roman,
  Please try this XSL...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
	
<xsl:template match="/root">
  <root>
    <xsl:for-each select="title">
      <layer>
        <title><xsl:value-of select="." /></title>
        <xsl:variable name="title-id"
select="generate-id()" />
        <xsl:for-each
select="following-sibling::para[generate-id(preceding-sibling::title[1])
= $title-id]">
          <para><xsl:value-of select="." /></para>
        </xsl:for-each>
      </layer>
    </xsl:for-each>
  </root>
</xsl:template>
	
</xsl:stylesheet>

Regards,
Mukul

--- Huditsch Roman <Roman.Huditsch@xxxxxxxxxxxxx>
wrote:

> Hi,
> 
>  
> 
> I am in search for a comfortable way for sructuring
> flat files.
> 
> Please take this source document as an example:
> 
>  
> 
> <?xml versio="1.0"?>
> 
> <root>
> 
>    <title>Titel 1</title>
> 
>   <para>Para 1</para>
> 
>   <para>Para 2</para>
> 
>   <para>Para 3</para>
> 
>   <title>Title 2</title>
> 
>   <para>Para 1</para>
> 
>   <para>Para 2</para>
> 
>   <title>Title 3</title>
> 
>   <para>Para 1</para>
> 
>   <para>Para 2</para>
> 
> </root>
> 
>  
> 
> After my XSLT 1,0 transformation the output should
> look like
> 
>  
> 
> <?xml versio="1.0"?>
> 
> <root>
> 
>    <layer>
> 
>      <title>Titel 1</title>
> 
>      <para>Para 1</para>
> 
>      <para>Para 2</para>
> 
>      <para>Para 3</para>
> 
>   </layer>
> 
>   <layer>
> 
>     <title>Title 2</title>
> 
>     <para>Para 1</para>
> 
>     <para>Para 2</para>
> 
>   </layer>
> 
>   <layer>  
> 
>     <title>Title 3</title>
> 
>     <para>Para 1</para>
> 
>     <para>Para 2</para>
> 
>   </layer>
> 
> </root>
> 
>  
> 
> Is there any way to do this? I don't know how to
> define "take all "para" nodes up to the next "title"
> element.....
> 
> Can you help me?
> 
> Thank you very much in advance.
> 
>  
> 
> Wbr,
> 
> Roman



		
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now. 
http://messenger.yahoo.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.