Re: [xsl] How do I properly extract data from different sections - XML file

Subject: Re: [xsl] How do I properly extract data from different sections - XML file
From: "Hank Ratzesberger xml@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Oct 2014 04:58:12 -0000
Firstly, I wonder why everyone else's transforms work without namespaces...

The following is an attempt to pass through the desired nodes (and
their text values) while avoiding the default template. (not what
Catherine ultimately wanted, and not complete).

Cheers,
Hank

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:xl="http://com/exlibris/repository/acq/invoice/xmlbeans";>

    <xsl:template
match="xl:payment_data|xl:invoice_list|xl:invoice|xl:invoice_number|xl:currency|xl:vendor_code|xl:invoice_line_list|xl:invoice_line|xl:fund_info_list|xl:fund_info">
        <xsl:copy>
            <xsl:value-of select="text()"/>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="text()|@*"></xsl:template>

</xsl:stylesheet>


Output:

<?xml version="1.0" encoding="UTF-8"?>
<payment_data xmlns="http://com/exlibris/repository/acq/invoice/xmlbeans";
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <invoice_list>
        <invoice>
            <invoice_number>PO-305</invoice_number>
            <currency>USD</currency>
            <vendor_code>ABE</vendor_code>
            <invoice_line_list>
                <invoice_line>
                    <fund_info_list>
                        <fund_info>
                            <currency>USD</currency>
                        </fund_info>
                    </fund_info_list>
                </invoice_line>
                <invoice_line>
                    <fund_info_list>
                        <fund_info>
                            <currency>USD</currency>
                        </fund_info>
                    </fund_info_list>
                </invoice_line>
                <invoice_line>
                </invoice_line>
                <invoice_line>
                </invoice_line>
                <invoice_line>
                </invoice_line>
            </invoice_line_list>
            <currency>CAD</currency>
        </invoice>
    </invoice_list>
</payment_data>

On Tue, Oct 21, 2014 at 9:04 AM, Catherine Wilbur cwilbur@xxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Here is XML file coming out of an Alma Library system - do not need all
> these fields just highlighted fields required.
>
> Catherine Wilbur  |  Senior Application Programmer  |  IT Services
>  (E) cwilbur@xxxxxxxxxxx
> XSL-List info and archive
> EasyUnsubscribe (by email)

[snip]

-- 
Hank Ratzesberger
XMLWerks.com

Current Thread