FDMilwaukee
asked on
XSL remove comma from output, but losing part of the text
I'm trying to remove any commas that a user inputs, which I've accomplished using a post I found here on Experts Exchange.
It's working well, except for one thing. It is now removing all text prior to the comma!
Thanks in advance for any suggestions!!!
-FDS
<xsl:value-of select="translate(../../shipping/street1,',','')" /><xsl:value-of select="$sepend" />
From what I had previously <xsl:value-of select="normalize-space(../../shipping/street1)"/><xsl:value-of select="$sepend" />
It's working well, except for one thing. It is now removing all text prior to the comma!
Thanks in advance for any suggestions!!!
-FDS
ASKER
Sure thing, here it is.....
It seems odd that I wasn't losing any of the text prior to changing the code to include translate.
<?xml version="1.0" encoding="UTF-8"?>
<files>
<file filename="customer_data.csv" path="/export" active="true" ftp="false">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="sepstart"/> <!-- " field start seperator, including '' -->
<xsl:variable name="sepend" select="','"/> <!-- field end seperator, including '' -->
<xsl:template match="/">
<xsl:text>"USERNAME","ORDER_NUMBER","ORDER_DATE","SUBTOTAL","SHIPPING","TAX","TOTAL","SHIP","SHIP_ADDRESS_1","SHIP_CITY","SHIP_STATE","SHIP_POSTAL","SHIP_COUNTRY","BILL_NAME","BILL_ADDRESS_1","BILL_CITY","BILL_STATE","BILL_LOCALITY","BILL_POSTAL","BILL_COUNTRY","PHONE_1"</xsl:text><xsl:text>
</xsl:text>
<xsl:for-each select="orders/order">
<xsl:for-each select="items/item">
<!--<xsl:if test="product_type!='configurable'">-->
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../customer_email)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../increment_id)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="php:functionString('strftime', '%m/%d/%Y', ../../created_at_timestamp)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../subtotal)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../payment/shipping_amount)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../tax_amount)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../total_paid)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="../../shipping/firstname"/><xsl:text> </xsl:text><xsl:value-of select=" ../../shipping/lastname"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="translate(../../shipping/street1,',','')" /><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../shipping/city)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../shipping/region)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../shipping/postcode)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../shipping/country_id)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../billing/firstname)"/><xsl:text> </xsl:text><xsl:value-of select="normalize-space(../../billing/lastname)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="translate(../../billing/street1,',','')" /><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../billing/city)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../billing/region)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../BLANK)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../billing/postcode)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../billing/country_id)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../billing/telephone)"/><xsl:value-of select="$sepend" />
<xsl:text>
</xsl:text>
<!--</xsl:if>-->
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</file>
</files>
It seems odd that I wasn't losing any of the text prior to changing the code to include translate.
are there multiple street1 elements at that location?, or maybe multiple text nodes?
not sure it should matter, but using an old libxslt, one never knows
Can you show me the source XML for this?
not sure it should matter, but using an old libxslt, one never knows
Can you show me the source XML for this?
ASKER
I'm not sure what you mean by "source xml"
An XSLT transforms an XML into antother XML
the source from which you start is the source XML
so the XML that is your start point for this transformation is what I need
the source from which you start is the source XML
so the XML that is your start point for this transformation is what I need
ASKER
Ok, gotcha that makes sense. I don't know how I would get that though. I assumed those values were being pulled directly from the database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
something else must do that
The translate function just replaces a ',' with a '', som removes the ','
Can we see the whole XSLT?