xsl-list
[Top] [All Lists]

[xsl] [XSL] Problem with selecting nodes

2010-09-02 10:03:16
I have a source XML file of the structure:
<MIS_Report>
        <Records>
                <XXXRecord>
                        <XXXRecordDetails>
                                <XXXRecordHeader/>
                                <XXXRecordVersion/>
                        </XXXRecordDetails>
                </XXXRecord>
        </Records>
</MIS_Report>

There are multiple XXXRecords in <Records> and XXXRecordVersion contains a 
number of descendant elements.

I am transforming the source via an XSLT (using Xalan).  I have a problem.  The 
output should look like

<RecordBatch>
        <BatchHeader/>
        <RecordMessage>
                <MessageHeader/>
                <RecordHeader/>
                <Record>
        </RecordMessage>
</RecordBatch>

With there being multiple RecordMessages, one for each XXXRecordVersion  in the 
source.

The relevant bit of XSLT is:

<xsl:template match = 
"/MIS_Report/Records/XXXRecord/XXXRecordDetails/XXXRecordVersion">
        Some XSLT that seems to work
        .....
        <RecordHeader>
        More XSLT that seems to work
        </RecordHeader>
        <xsl:apply-templates select="//RecordVersion" mode="Copy" />
        </RecordMessage>
</xsl:template>

<xsl:template match="*" mode="copy">
        XSLT that seems to work
</xsl:template>

The issue is that the </RecordMessage> tag is never reached.  My output looks 
like


<RecordBatch>
        <BatchHeader/>
        <RecordMessage>
                <MessageHeader/>
                <RecordHeader/>
                <Record>
                <MessageHeader/>
                <RecordHeader/>
                <Record>
                <MessageHeader/>
                <RecordHeader/>
                <Record>etc
        </RecordMessage>
</RecordBatch>

i.e. I end up with a RecordMessage of 38 records, instead of 38 RecordMessages!

I have done something very silly, but I cannot see what.

Any help would be gratefully received.
        
        

Stephen Etheridge | Managing Consultant, Information Management, Business 
Optimisation Team
250 Brook Drive, Green Park, Reading RG2 6UA | United Kingdom
M: +44 7796 336 567
stephen(_dot_)etheridge(_at_)logica(_dot_)com | www.logica.com
Registered in England & Wales (registered number 947968)   
Registered Office: 250 Brook Drive, Green Park, Reading RG2 6UA, United Kingdom


Please help Logica to respect the environment by not printing this email  / 
Pour contribuer comme Logica au respect de l'environnement, merci de ne pas 
imprimer ce mail /  Bitte drucken Sie diese Nachricht nicht aus und helfen Sie 
so Logica dabei, die Umwelt zu schützen. /  Por favor ajude a Logica a 
respeitar o ambiente nao imprimindo este correio electronico.



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.



--~------------------------------------------------------------------
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>