Neil Thompson
asked on
create text file from xml file - full xslt needed please
https://www.experts-exchange.com
Hi
I have the following XML file that I need to extract the data out of into text format (a line for each entire )for each <ReturnedDebitItem> node, can someone help with the XSLT please?
I'm ok with the very basics and currently use the following batch file and xalan.jar, xercesImpl.jar and xmlParserAPIs.jar called with the following batch file:
convert.bat
-----------
echo off
if not exist .\build-listed-buildings.b at goto ERROR
set CP=.\xalan.jar;.\xmlParser APIs.jar;. \xercesImp l.jar
echo on
java -cp %CP% org.apache.xalan.xslt.Proc ess -IN .\sd_arudd_270707.xml -XSL .\sd_arudd.xsl -OUT .\result.txt
echo off
goto END
:ERROR
echo This 'bat' file can only run from the root of the folder -- please 'cdir' to this folder then try again
goto END
:END
pause
echo on
-------------------------- ---------- --
<?xml version="1.0" encoding="UTF-8"?>
<BACSDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat ion="newba cs-advices .xsd">
<Data>
<ARUDD>
<Header reportType="abc123" adviceNumber="123" currentProcessingDate="200 7-07-27">< /Header>
<AddresseeInformation name="test"></AddresseeInf ormation>
<ServiceLicenseInformation userName="test" userNumber="123"></Service LicenseInf ormation>
<Advice>
<OriginatingAccountRecords >
<OriginatingAccountRecord>
<OriginatingAccount name="ABC HHGGDD P" number="22334455" sortCode="00-00-00" type="0" bankName="My Bank" branchName="High ROAD"></OriginatingAccount >
<ReturnedDebitItem ref="PAR123 " transCode="66" returnCode="333" returnDescription="asdsad" originalProcessingDate="20 07-07-25" valueOf="25.00" currency="GBP"><PayerAccou nt number="12345678" ref="P00531 " name="asdfg & dsfsdf" sortCode="01-01-01" bankName="My Bank 1" branchName="HIGH STREET"></PayerAccount></R eturnedDeb itItem>
<ReturnedDebitItem ref="PAR123 " transCode="77" returnCode="444" returnDescription="asdasd" originalProcessingDate="20 07-07-25" valueOf="75.00" currency="GBP"><PayerAccou nt number="87654321" ref="P00674 " name="zxccxz & dsfsdf" sortCode="02-02-02" bankName="My Bank 2" branchName="LOW STREET"></PayerAccount></R eturnedDeb itItem>
<Totals numberOf="2" valueOf="100..00" currency="GBP"></Totals>
</OriginatingAccountRecord >
</OriginatingAccountRecord s>
</Advice>
</ARUDD>
</Data>
<SignatureMethod></Signatu reMethod>
<Signature></Signature>
</BACSDocument>
Hi
I have the following XML file that I need to extract the data out of into text format (a line for each entire )for each <ReturnedDebitItem> node, can someone help with the XSLT please?
I'm ok with the very basics and currently use the following batch file and xalan.jar, xercesImpl.jar and xmlParserAPIs.jar called with the following batch file:
convert.bat
-----------
echo off
if not exist .\build-listed-buildings.b
set CP=.\xalan.jar;.\xmlParser
echo on
java -cp %CP% org.apache.xalan.xslt.Proc
echo off
goto END
:ERROR
echo This 'bat' file can only run from the root of the folder -- please 'cdir' to this folder then try again
goto END
:END
pause
echo on
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<BACSDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat
<Data>
<ARUDD>
<Header reportType="abc123" adviceNumber="123" currentProcessingDate="200
<AddresseeInformation name="test"></AddresseeInf
<ServiceLicenseInformation
<Advice>
<OriginatingAccountRecords
<OriginatingAccountRecord>
<OriginatingAccount name="ABC HHGGDD P" number="22334455" sortCode="00-00-00" type="0" bankName="My Bank" branchName="High ROAD"></OriginatingAccount
<ReturnedDebitItem ref="PAR123 " transCode="66" returnCode="333" returnDescription="asdsad"
<ReturnedDebitItem ref="PAR123 " transCode="77" returnCode="444" returnDescription="asdasd"
<Totals numberOf="2" valueOf="100..00" currency="GBP"></Totals>
</OriginatingAccountRecord
</OriginatingAccountRecord
</Advice>
</ARUDD>
</Data>
<SignatureMethod></Signatu
<Signature></Signature>
</BACSDocument>
ASKER
superb but i forgot to say i need to add extra bits and remove others, how would I grab the parts of each of these repeating elements?
neil
neil
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Superb, very clear thank you
Neil
Neil
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="text" indent="no" />
<xsl:template match="ReturnedDebitItem">
<xsl:for-each select="@*">
<xsl:value-of select="." /><xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>