xsl-list
[Top] [All Lists]

Problem generating default attribute values.

2002-11-15 04:33:21
I couldn't find anything specific to my problem in the FAQ - although 
it is related to flattening..

I have the following XML input.

<transaction-list>
        <transaction total="T1" >
           <breakdown account="B" amount="Y" />
           <breakdown account="D" amount="Z" />
           <breakdown account="A" amount="X" />
         <!-- no two breakdown children have -->
         <!-- the same account attribute value --> 
        </transaction>
        
        <transaction total="T2" >
           <breakdown account="B" amount="P" />
           <breakdown account="A" amount="R" />
           <breakdown account="C" amount="Q" />
         <!-- no two breakdown children have -->
         <!-- the same account attribute value --> 
        </transaction>
</transaction-list>

I would like to generate this.

<dest-transaction-list total="total" A="A" B="B" C="C" D="D">
        <dest-transaction   total="T1" A="X" B="Y" C="0" D="Z"/>
        <dest-transaction   total="T2" A="R" B="P" C="Q" D="0"/>
</dest-transaction-list>

Each transaction should map to a dest-transaction element, which
is a straightforward transformation, apart from one thing.

Each dest-transaction needs to have an attribute value for every account
attribute value. If the particular account attribute value does
not exist as a child of the corresponding transaction/breakdown 
element, then it should output a zero '0'.

I hope the XML is clearer than my explanation or the subject title..

-Jon


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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