[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Transforming a non-hierarchical XML into a hierar
Subject: Re: Transforming a non-hierarchical XML into a hierarchical one
From: SEXpeare <sexpeare@xxxxxxxxx>
Date: Thu, 8 Mar 2007 13:49:54 +0100
|
thx very much both of U, you have solved my problem, now i'm trying to
apply this to another part of the document where the nodes are all the
same with an attribute giving their class, I think I can do it but if
I can't I will have to disturb you again with my questions, thx in
advance
2007/3/8, Michael Kay <mike@xxxxxxxxxxxx>:
If the sections aren't recursive (different element name used at each level)
then you can do something like
<xsl:for-each-group select="*"
group-starting-with="section">
<section>
<h1>...</h1>
<xsl:for-each-group select="current-group()[position() ne 1]"
group-starting-with="sub-section">
<h2>...</h2>
<xsl:for-each-group select="current-group()[position() ne 1]"
group-starting-with="sub-sub-section">
<h3>...</h3>
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: SEXpeare [mailto:sexpeare@xxxxxxxxx]
> Sent: 08 March 2007 11:23
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: Transforming a non-hierarchical XML into a
> hierarchical one
>
> a 2.0 solution would be great, thx for your time, i have been
> working with xsl-fo for a time, but never had to do
> complicated transformations like this one, i want to learn
> all i can from you ;)
>
> 2007/3/8, Michael Kay <mike@xxxxxxxxxxxx>:
> >
> > I'm guessing from your choice of element names that your hierarchic
> > structure is positional rather than defined by pointers.
> >
> > This makes it a positional grouping problem. Such problems
> are always
> > much easier in XSLT 2.0, so you need to make it clear
> whether you want
> > a 1.0 or a 2.0 solution.
> >
> > Michael Kay
> > http://www.saxonica.com/
> >
> > > -----Original Message-----
> > > From: SEXpeare [mailto:sexpeare@xxxxxxxxx]
> > > Sent: 08 March 2007 10:20
> > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > Subject: Transforming a non-hierarchical XML into a
> > > hierarchical one
> > >
> > > Hello everybody, I have to transform a non hierarchical XML:
> > >
> > > <sumario>
> > > <seccion txt=""/>
> > > <subseccion txt=""/>
> > > <organismo txt=""/>
> > > <anuncio txt=""/>
> > > <organismo txt=""/>
> > > <anuncio txt=""/>
> > > <organismo txt=""/>
> > > <anuncio txt=""/>
> > > <subseccion txt=""/>
> > > <organismo txt=""/>
> > > <anuncio txt=""/>
> > > <seccion txt=""/>
> > > <subseccion txt=""/>
> > > <organismo txt=""/>
> > > <anuncio txt=""/>
> > > ...
> > > </sumario>
> > >
> > > into a hierarchical XML, doing this via XSLT. The result must be
> > > like this:
> > >
> > > <sumario>
> > > <seccion id="">
> > > <subseccion id="">
> > > <organismo id="">
> > > <anuncio>
> > > </anuncio>
> > > ...
> > >
> > > </organismo>
> > > </subseccion>
> > > </seccion>
> > > ...
> > > </sumario>
> > >
> > > I would apreciate any idea or advice, thx.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|