RE: [xsl] XSLT and comma's in XML data

Subject: RE: [xsl] XSLT and comma's in XML data
From: "Pawson, David" <David.Pawson@xxxxxxxxxxx>
Date: Thu, 17 Feb 2005 09:58:58 -0000
*if* you have office tools,
open the file in excel, then save again,
using something other than comma as the separator
(I found pipe  to be useful).

M$ has quite regular rules for csv export,
just that they don't advertise them.

HTH DaveP.
may help

    CSV files unfortunately have many conventions but no 
    standards. One of the conventions is that when a field 
    contains a comma, you put the field in quotes. I've no idea 
    what you are supposed to do if the field also contains 
    quotes. It would probably be a good idea to do some 
    experiments with the software that's expected to read this CSV file.
    It probably does no harm to put the field in quotes 
    unconditionally: I assume you can tackle that on your own.
    Michael Kay
    > -----Original Message-----
    > From: Ian Vaughan [mailto:i.vaughan@xxxxxxxxxxxxxxxxxxxxxxx]
    > Sent: 17 February 2005 09:02
    > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
    > Subject: [xsl] XSLT and comma's in XML data
    > I am having a problem with my XML a snippet of which is 
    shown below
    > <PropertyAddress>
    > <apd:A_5LineAddress>
    > 	<apd:Line>Bank, Street</apd:Line> 
    > 	<apd:Line /> 
    > 	<apd:Line /> 
    > 	<apd:Line>Town</apd:Line>
    > <apd:PostCode></apd:PostCode>
    > </apd:A_5LineAddress>
    > </PropertyAddress>
    > ...........................etc
    > The problem I am finding is that in the XML some fields such as 
    > <apd:Line> sometimes has data that contains a comma such as 
    > 'Bank,Street'
    > Then when parsing this through the XSLT it is locating the comma 
    > seperating 'Bank,Street' and splitting up the data
    > Any ideas on a solution would be most helpful
    > This is the XSLT
    > ----------------------------------------------------------
    > <xsl:stylesheet version="1.0"
    > xmlns:xsl="";
    > xmlns:apd="
    > Details">
    > <xsl:output method="text" />
    > <xsl:template match="/">
    > <xsl:text>UniqueRecordID, RegistrationNumber, RegisteredName, 
    > Address1, Address2, Address3, Address4,PostCode, DateComplete, 
    > DescriptionOfWorkItems </xsl:text> <xsl:apply-templates 
    > select="//BuildingRecord"/> </xsl:template>
    > <xsl:template match="BuildingRecord">
    > <xsl:text>&#10;</xsl:text>
    > <xsl:apply-templates select=".//*[not(*)]  | .//apd:*/*"/> 
    > </xsl:template>
    > <xsl:template match="BuildingRecord//* | apd:*/* "> <xsl:if 
    > test="position() &gt; 1 ">,</xsl:if> <xsl:value-of 
    > select="normalize-space(.)"/> </xsl:template>
    > </xsl:stylesheet>
    > -----------------------------------------------------------


NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged.  If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227


Current Thread