.NETGURU
condiational XSLT transformation
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngxml' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Brian Bilbro (VIP)
I have an ASP.NET application that outputs XML and then does a
transformation into other format using XSLT. One of the formats it outputs
is comma delimited. However, it doesn't really check the data. I need it
to quote (") any fields with a comma in it and if any fields have a quote
within it I need it to surround that with quote (") and double quote the
quote (like so..."").

However, this code was developed by somebody else and my XSLT skills is
zero. :) I figure this is a simple thing, I just don't know how to do it.
The XSLT file follows.

Thanks,
Brian

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" indent="no" encoding="ISO-8859-1"/>
<xsl:template match="NewDataSet">
<xsl:for-each select="DetailData">
<xsl:for-each select="@*" >
<xsl:value-of select="." />
<xsl:if test="position()!=last()">,</xsl:if>
</xsl:for-each>
<xsl:if test="position()!=last()"> </xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Reply to this message...
 
    
Dan Wahlin
There's no simple answer to this problem with XSLT unfortunately. It
does have a translate() function but it is generally used to replace one
character with another (not a string of characters). You're going to
have to resort to recursive template calling more than likely. I don't
have a sample on hand but had bookmarked the following code that you can
view on Google. It should help get you started:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=ynRG8.6
24%24o%25.78770%40news8-gui.server.ntli.net&rnum=10

(watch for URL wrapping)

HTH,
Dan Wahlin

Wahlin Consulting LLC
Microsoft MVP - ASP.NET
http://www.XMLforASP.Net: #1 ASP.NET XML Resource
XML for ASP.NET Developers by Dan Wahlin in bookstores everywhere!

-----Original Message-----
From: Brian Bilbro [mailto:Click here to reveal e-mail address]
Sent: Friday, July 12, 2002 7:23 AM
To: aspngxml
Subject: [aspngxml] condiational XSLT transformation

I have an ASP.NET application that outputs XML and then does a
transformation into other format using XSLT. One of the formats it
outputs
is comma delimited. However, it doesn't really check the data. I need
it
to quote (") any fields with a comma in it and if any fields have a
quote
within it I need it to surround that with quote (") and double quote the
quote (like so..."").

However, this code was developed by somebody else and my XSLT skills is
zero. :) I figure this is a simple thing, I just don't know how to do
it.
The XSLT file follows.

Thanks,
Brian

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" indent="no" encoding="ISO-8859-1"/>
<xsl:template match="NewDataSet">
<xsl:for-each select="DetailData">
<xsl:for-each select="@*" >
<xsl:value-of select="." />
<xsl:if test="position()!=last()">,</xsl:if>
</xsl:for-each>
<xsl:if test="position()!=last()"> </xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

| [aspngxml] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngxml.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification