Re: [xsl] XSL: parsing

Subject: Re: [xsl] XSL: parsing
From: Jeff Sese <jeferson.sese@xxxxxxxxxxxx>
Date: Tue, 12 Aug 2008 18:01:37 +0800
On 08 12, 08, at 5:39 PM, Sathasivam, Elayaraja wrote:

Thanks for your mail.

Find the details as follows,

$conf: <xsl:variable name="conf" select="document ('bgh_config.xml')"/>
No issues, just loading the input xml file.
$TZ : TZ003
$TM: TZAOP


Expected output: FIXED
Actual Output: Debug < No output of @brk ???? >

$xalan -o Output.txt Index.xml File.xsl

Index.xml
*********
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
  <Part File='DET184.5371.0.xml' LinkType='REL' DocType='DET'
Format='XML'/>
</Envelope>


File.xsl ********** <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:date="http://exslt.org/dates-and-times"; exclude-result-prefixes="xsl"> <xsl:output method="text" media-type="text/plain" />

<xsl:variable name="conf" select="document('bgh_config.xml')"/>

<xsl:template match="/" >
<xsl:for-each
select="document(/Envelope/Part/@File)/Document/CallDetails/Call">
<xsl:variable name="TZ" select="XCD/@TZ"/>
<xsl:variable name="TM" select="XCD/@TM"/>
<xsl:choose>
<xsl:when
test="$conf/Configuration/BreakdownList/BreakdownMatrix/BrkSection [@tm=$
TM]/BrkCode[tz=$TZ]"> Debug
<xsl:value-of select="@brk"/>
In this part of the xsl file, the current node is the Call element if your DET184.5371.0.xml file, iterated via xsl:for-each. The @brk is in the BrkCode element of the bgh_config.xml, which is in turn assigned to the variable $conf. To get the value of @brk you must access it via the $conf variable. Try using this xpath expression. $conf/Configuration/BreakdownList/BreakdownMatrix/BrkSection/BrkCode/ @brk.

		</xsl:when>
		<xsl:otherwise> Otherwise </xsl:otherwise>
	</xsl:choose>	
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>


DET184.5371.0.xml ***************** <?xml version="1.0" encoding="UTF-8"?> <Document> <CallDetails> <Call>

<XCD DV="40" Id="26231918" UM="" DC="0.000000"
OAmt="0.000" DAmt="1.000" CC="EGP" TM="TZAOP" SN="RTEL" TT="ETP01WOP01"
TZ="TZ003" RT="BASE" CTI="0" CT="1" RTON="1" APN="111635766" NI="H"
NN="EGYEM" ANP="APN" URP="1" TTR="0.000" DES="NV" DZP="gprse"
CGI="60203" OPN="etisalat" UV="544.000000" DLV="565.000000" RQSP="0"
RQSR="0" RQSD="0" RQSPT="0" RQSMT="0" NQSP="0" NQSR="0" NQSD="0"
NQSPT="0" NQSMT="0" DAV="1109.000000" DAUM="GPRS" CQV="544.000000"
CQUM="Byte" SP="GSP" />
</Call>
</CallDetails>
</Document>



bgh_config.xml ************** <?xml version="1.0" encoding="UTF-8"?> <Configuration> <BreakdownList> <BreakdownMatrix> <BrkSection tm="TZAOP" comment="T-Mobile Zakelijk Optimaal (+variants) and Data Connect, Special Edition rateplans and Team Totaal (Dura)"> <BrkCode brk="FIXED" comment="Vaste nummers: fixed + WAP"> <tz>TZ001</tz> <tz>TZ003</tz> </BrkCode> </BrkSection> </BreakdownMatrix> </BreakdownList> </Configuration>


Regards, Raja _________________________________________________________________


Jeferson L. Sese jeferson dot sese at asiatype dot com Asiatype Inc. Suite 114 Columbia Tower Ortigas Ave., Greenhills Mandaluyong City 1550 Philippines Tel: +632-744-6262 Mobile: +63927-671-7901

Current Thread