Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: help using XSLT in parsing nested xml trees

From: binary_sunset@-----.---
To: NULL
Date: 4/2/2007 8:15:00 AM

On Mar 30, 12:19 am, p.le...@ctncorp.com wrote:
> On Mar 30, 12:49 am, binary_sun...@yahoo.com wrote:
>
>
>
> > <article>
> >    <title/>
> >    <date/>
> >    <body/>
> >    <article>
> >       <title/>
> >       <date/>
> >       <body/>
> >       <article>
> >           <title/>
> >           <date/>
> >           <body/>
> >        </article>
> >    </article>
> > </article>
>
> > The desired output from an XSLT would be something like
> > three separate files (easy) with the structure:
>
> Unless I'm much mistaken, XSLT1 cannot produce several
> result trees in one pass. For that matter, I'm not sure it
> can be done with EXSLT; and XSLT2 implementations are not
> that common yet.
>
>
>
> > or at least:
>
> > <article>
> >    <title/>
> >    <date/>
> >    <body/>
> > </article>
> > <article>
> >    <title/>
> >    <date/>
> >    <body/>
> > </article>
> > <article>
> >    <title/>
> >    <date/>
> >    <body/>
> > </article>
>
> > So how do I parse the output? It looks like a recursive
> > process, as the number of nestings will vary with the
> > number of articles in the signature, and by magazine. The
> > idea of attaching an attribute <article id="n"> to each
> > article occurred to me, but this changes the workflow
> > somewhat, as ids were to be established in
> > post-processing, rather than by hand.
>
> Perhaps I'm missing something, but unnesting the structure
> described seems trivial enough to me:
>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:template match="/">
>     <unnested-articles>
>       <xsl:apply-templates select="//article"/>
>     </unnested-articles>
>   </xsl:template>
>   <xsl:template match="article">
>     <xsl:copy>
>       <xsl:apply-templates
>         select="@*|node()" mode="clone"/>
>     </xsl:copy>
>   </xsl:template>
>   <xsl:template match="@*|node()" mode="clone">
>     <xsl:copy>
>       <xsl:apply-templates
>         select="@*|node()" mode="clone"/>
>     </xsl:copy>
>   </xsl:template>
>   <xsl:template match="article" mode="clone"/>
> </xsl:stylesheet>
>
> --
> Pavel Lepin

Great! Thanks... This looks like it will work for now, and I'm going
to pursue a dialogue with the folks at Adobe to see why the XML is
being formatted like that in the first place, and if there is a way to
configure it differently.

Much appreciated.
MC




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent