xsl-list
[Top] [All Lists]

[xsl] Positional Grouping problem

2006-05-29 00:30:35
I have read the FAQ and think I have found a partial answer to my
problem.  Seems to be Positional Grouping solution (10)
http://www.dpawson.co.uk/xsl/sect2/N4486.html

but my xslt skills are too weak to understand the solution!.  I can't
even get the solution to work - been at this for hours now... very bad I
know.


I have the following XML  - a Batch of Invoices  a 3 line Invoice and a
2 line Invoice (there are a bunch of other tags and data inside these
but for simplicity I've left then out in this example).

 

<invoices>
 <invoiceHeader> ...</invoiceHeader>
 <invoiceLine>... </invoiceLine>
 <invoiceLine>... </invoiceLine>
 <invoiceLine>... </invoiceLine>
 <invoiceHeader>... </invoiceHeader>
 <invoiceLine>... </invoiceLine>
 <invoiceLine>... </invoiceLine> 
</invoices>


What I need is a <invoice> tag that surrounds the Header and Lines.
There is nothing that relates a Header to a Line apart from its position
i.e the header will be followed by its lines.

<invoices>
 <invoice>
   <invoiceHeader> ...</invoiceHeader>
   <invoiceLine>... </invoiceLine>
   <invoiceLine>... </invoiceLine>
   <invoiceLine>... </invoiceLine>
 </invoice>
 <invoice>
   <invoiceHeader>... </invoiceHeader>
   <invoiceLine>... </invoiceLine>
   <invoiceLine>... </invoiceLine> 
 <invoice>
</invoices>


How can I do this ?

Something like the partial example snippet given in the FAQ above would
give the following - but can somebody fill in the blanks  - I am missing
the start template statements etc - but I do not know what they are
meant to be.

   <xsl:for-each select=="invoiceHeader">

         <invoice>
            <invoiceHeader><xsl:value-of select="." />
            </invoiceHeader>

            <invoiceLine>
               <xsl:for-each select=="following-sibling::invoiceLine[
count(preceding-sibling::invoiceHeader[1] | current()) == 1]">
               <xsl:value-of select=="invoiceLine" />
               </xsl:for-each>
            </invoiceLine>
         </invoice>

    </xsl:for-each>

 

Thanks for any assistance

Peter 

***********************************************************************
The information contained in this email and any attachments may be confidential 
and is provided solely for the use of the intended recipient(s). If you are not 
the intended recipient, you are hereby notified that any disclosure, 
distribution, or use of this e-mail, its attachments or any information 
contained  therein is unauthorised and prohibited. If you have received this in 
error, please contact the sender immediately and delete this e-mail and any 
attachments. 

No responsibility is accepted for any virus or defect that might arise from 
opening this e-mail or attachments, whether or not it has been checked by 
anti-virus software.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>