Altova Mailing List Archives


Re: Convert xml to CSV using xsltproc

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 2/21/2010 6:40:00 PM
loc wrote:
> On Feb 21, 6:10 am, Martin Honnen <mahotr...@yahoo.de> wrote:

>> Then process each 'TransactionLine' element and output what you want to
>> output:
>>
>> <xsl:stylesheet
>>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>    version="1.0">
>>
>>    <xsl:strip-space elements="*"/>
>>    <xsl:output method="text"/>
>>
>>    <xsl:template match="/">
>>      <xsl:apply-templates
>> select="NAXML-POSJournal/JournalReport/SaleEvent/TransactionDetailGroup/TransactionLine"/>
>>    </xsl:template>
>>
>>    <xsl:template match="TransactionLine">
>>      <xsl:value-of
>> select="/NAXML-POSJournal/TransmissionHeader/StoreLocationID"/>
>>      <xsl:text>,</xsl:text>
>>      <xsl:value-of
>> select="/NAXML-POSJournal/JournalReport/SaleEvent/BusinessDate"/>
>>      <xsl:text>,</xsl:text>
>>      <xsl:value-of select="ItemLine/ItemCode/POSCodeFormat/@format"/>
>>      <xsl:text>,</xsl:text>
>>      <xsl:value-of select="ItemLine/ItemCode/POSCode"/>
>>      <xsl:text>&#xA;</xsl:text>
>>    </xsl:template>
>>
>> </xsl:stylesheet>

> Thanks, it works great, just what I wanted.  One question, I'm just
> trying to get a better understanding of how this works, why isn't a
> for-each needed even though there are multiple matches for
> <TransactionLine> and the data under it?

The apply-templates 
select="NAXML-POSJournal/JournalReport/SaleEvent/TransactionDetailGroup/TransactionLine" 
selects all 'TransactionLine' elements for processing, that is the 
reason you do not need a for-each.

-- 

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.