Subject: Re: [xsl] change xslt processing order From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 26 Sep 2011 16:28:41 -0400 |
I have been trying to solve this problem for a while but I haven't had much luck.
I have attached the xml and the xslt file below, My desired output for the given xml is:
Expected out: JD0002210800004322 7255 044375530 JD0002210800004323 7256 044375531 JD0002210800004324 JD0002210800004325 7257 044375532
but I am getting the following output:
t:\ftemp>type navin.xml <?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"/> <Parcel RECORD_TYPE="PA" MANIFEST_NO="0000000000" PARCEL_NO="JD0002210800004325"/> <TrailerRecord RECORD_TYPE="TR" NO_RECORDS="00000425"/> </MR23030B> t:\ftemp>xslt navin.xml navin.xsl JD0002210800004322 7255 044375530 JD0002210800004323 7256 044375531 JD0002210800004324 7257 044375532 JD0002210800004325
t:\ftemp>type navin.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method='text'/>
<xsl:key name="parcelDetailsForAddress" match="DeliveryAddress" use="following-sibling::Parcel[1]/@PARCEL_NO"/> <xsl:key name="parcelDetailsForConsignment" match="Consignment" use="following-sibling::Parcel[1]/@PARCEL_NO"/>
<xsl:variable name='newline'> <xsl:text> </xsl:text> </xsl:variable> <xsl:template match="MR23030B"> <xsl:apply-templates select="Parcel"/> </xsl:template>
<xsl:template match="Parcel"> <xsl:value-of select="@PARCEL_NO"/> <xsl:value-of select="$newline"/> <xsl:apply-templates select="key('parcelDetailsForAddress',@PARCEL_NO)"/> <xsl:apply-templates select="key('parcelDetailsForConsignment',@PARCEL_NO)"/> </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:template>
</xsl:stylesheet> t:\ftemp>
-- Contact us for world-wide XML consulting and instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] change xslt processing order, Navin Patel | Thread | Re: [xsl] change xslt processing or, Navin Patel |
[xsl] change xslt processing order, Navin Patel | Date | [xsl] XPath that returns nothing, Olivier Lefevre |
Month |