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

Re: transforming flat structure with xsl 2.0 grouping

Subject: Re: transforming flat structure with xsl 2.0 grouping
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Mon, 20 May 2013 19:08:32 +0200
Re:  transforming flat structure with xsl 2.0 grouping
Hi Charles,

Please find a stylesheet here: http://www.sharexml.com/x/get?k=SvrKGijHKYIz

If it still doesnbt solve the problem, then the problem is underdetermined.

Your approach (presumably) consisted of transforming using apply-templates in default mode and whenever you hit a Warning or a Note, you tried to collect the following siblings that belong to them. Your approach should have grouped all following siblings, including the ones that belong to the next Note (but also those that belong to the next Warning, unless youbve split the document at each Warning in a first pass.

So Ibm proposing that you do a nested for-each-group. The first one groups the steps, where each step starts with a Warning. The inner for-each-group groups each of the steps at each Warning, Note, or ProcStep.

Instead of the outer for-each-group starting at each Warning, you could do an outer group-ending-with grouping at each ProcStep and then do the inner Warning | Note | ProcStep group-starting-with grouping.

Gerrit


On 20.05.2013 17:55, Charlie 0 wrote:
I have an extremely flat structure exported from Framemaker (not
structured). The elements are created from style names and the
structure is completely flat. Just about everything is a sibling of
everything else.

I am transforming this flat structure to a proprietary content model
(DTD). The entire project consists of a lot of group. Most of which
I have a handle on. However there is aspect I could use some help with.

I have an XML input structure that something like this:

<XML>
<Warning>
</Warning>
<WarnHazText>Cleaning solvent </WarnHazText>
<WarnHazText>Wear eye</WarnHazText>
<ProcStep>All weldel.</ProcStep>
<Warning>
</Warning>
<WarnHazText>Cleaning solvent </WarnHazText>
<WarnHazText>Wear eye</WarnHazText>
<HazText>CARC </HazText>
<HazText>ALWAYS follow /HazText>
<Note></Note>
<HazText>When using a torch</HazText>
<ProcStep>All weldel.</ProcStep>
</XML>

Or it could look like this:

<XML>
<ProcStep>All weldel.</ProcStep>
<Warning>
</Warning>
<Graphic>
     <IMAGE  href="icon-30.gif"/>
</Graphic>
<WarnHazText>Cleaning solvent </WarnHazText>
<WarnHazText>Wear eye</WarnHazText>
<HazText>CARC </HazText>
<HazText>ALWAYS follow /HazText>
<ProcStep>All weldel.</ProcStep>
</XML>
What output would you like from both of those inputs?  You don't show
that ... you only show your code.

The problem with trying to "fix" the templates you have is that you
may have started out on the wrong foot.  It is difficult from your
prose description to deduce what end structures you want from the
above when the transformation is done.  Knowing what you want from
what you have (and if you have further examples, all the better)
would help a volunteer understand the requirement better.

. . . . . . . Ken

--
------------------------------

Ken,

I realized later that evening I hit "send" too soon.

The desired output:

<XML>
<step1>
     <specpara>
         <warning>
             <trim.para>Cleaning solvent</trim.para>
             <trim.para>Wear eye</trim.para>
         </warning>
         <para>All welds.</para>
     </specpara>
</step1>
<step1>
     <specpara>
         <warning>
             <trim.para>Cleaning solvent </WarnHazText>
                 <trim.para>Wear eye</trim.para>
                 <trim.para>CARC </trim.para>
                 <trim.para>ALWAYS follow </trim.para>
         </warning>
         <note>
             <trim.para>When using a torch</trim.para>
         </note>
         <para>All weldel. </para>
     </specpara>
</step1>
</XML>

Charles F.

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.