Hi,

I have this xml file, in my XSLT file I want to process <Parcel .../> element first then the <DeliveryAdress ../> and then the <Consignment .../> element.

I would be very grateful if someone could suggest a solution please.

Thanks in advance.


<xml version="1.0" ?>

<MR23030B>

<Header RECORD_TYPE="HD" METER_NO="10800" FILE_DATE="23/06/2011" RUN_NUMBER="000909"
NO_RECORDS="00000425" LAYOUT_VERSION="000002" GAZ_VERSION="000107" />

<SenderAddress RECORD_TYPE="AS" COUNTRY_CODE="GB" BRANCH_PREFIX="" BRANCH_CODE=""
EUROEXPRESS_ACNT="" />

<Consignment RECORD_TYPE="CO" ACNT_NO="044375530" CONT_NO="9360964" COLL_PT="0001"
AND ACCESSORIES" />

<DeliveryAddress RECORD_TYPE="AD" COUNTRY_CODE="GB" BRANCH_PREFIX="07"
CNCT_FAX="" CNCT_VAT="" CNCT_E_EMAIL="" ACNT_IN_PARTNER="" EUROEXPRESS_ACNT="" />

<Parcel RECORD_TYPE="PA" MANIFEST_NO="0000000000" NOTE_NO="001"
PARCEL_CONTENT="CARD AND ACCESSORIES" />

<TrailerRecord RECORD_TYPE="TR" NO_RECORDS="00000425" />
</MR23030B>

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="mr23030b.xsl"?>
<MR23030B>
<Header RECORD_TYPE="HD" METER_NO="10800" FILE_DATE="23/06/2011" RUN_NUMBER="000909"/>
<SenderAddress RECORD_TYPE="AS" COUNTRY_CODE="GB" BRANCH_PREFIX="" BRANCH_CODE=""/>
<Consignment RECORD_TYPE="CO" ACNT_NO="044375530" CONT_NO="9360964" COLL_PT="0001"/>
<DeliveryAddress RECORD_TYPE="AD" COUNTRY_CODE="GB" BRANCH_PREFIX="07"

BRANCH_CODE="7255"/>
<Parcel RECORD_TYPE="PA" MANIFEST_NO="0000000000" PARCEL_NO="JD0002210800004322"/>
<Consignment RECORD_TYPE="CO" ACNT_NO="044375531" CONT_NO="9360964" COLL_PT="0001"/>
<DeliveryAddress RECORD_TYPE="AD" COUNTRY_CODE="GB" BRANCH_PREFIX="07"

BRANCH_CODE="7256"/>
<Parcel RECORD_TYPE="PA" MANIFEST_NO="0000000000" PARCEL_NO="JD0002210800004323"/>
<Consignment RECORD_TYPE="CO" ACNT_NO="044375532" CONT_NO="9360964" COLL_PT="0001"/>
<DeliveryAddress RECORD_TYPE="AD" COUNTRY_CODE="GB" BRANCH_PREFIX="07"

BRANCH_CODE="7257"/>
<Parcel RECORD_TYPE="PA" MANIFEST_NO="0000000000" PARCEL_NO="JD0002210800004324"/>
<TrailerRecord RECORD_TYPE="TR" NO_RECORDS="00000425"/>
</MR23030B>

I have the xml as shown abovw, but with XSL style sheet I ahve attached, I get all the

parcels first, then the Address and then the consignment info.as show below, but I want the

data to come out as parcel,Address Consignment,parcel,Address Consignment,parcel,Address

Consignment etc.

<?xml version="1.0" encoding="UTF-16"?>
JD0002210800004322
JD0002210800004323
JD0002210800004324
7255
7256
7257
0443
755...
i.e
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="MR23030B">
<xsl:apply-templates select="Parcel"/>
<xsl:apply-templates select="DeliveryAddress"/>
<xsl:apply-templates select="Consignment"/>
</xsl:template>

<xsl:variable name='newline'>
<xsl:text> </xsl:text>
</xsl:variable>

<xsl:template match="Parcel">
<xsl:value-of select="@PARCEL_NO"/>
<xsl:value-of select="$newline"/>
</xsl:template>

<xsl:template match="DeliveryAddress">
<xsl:value-of select="@BRANCH_CODE"/>
<xsl:value-of select="$newline"/>
</xsl:template>

<xsl:template match="Consignment">
<xsl:value-of select="@ACNT_NO"/>
<xsl:value-of select="$newline"/>
<xsl:value-of select="$newline"/>
</xsl:template>
</xsl:stylesheet>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.