Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 2nd, 2016, 11:13 AM
Registered User
 
Join Date: Aug 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shortening an output file name using XSLT in Magento

First of all, please accept my apologies if I say stupid things in my post1 I really don't understand this programming language and have only got so far through trial and error!

Here is my xsl template so far:

<?xml version="1.0"?>
<files>
<file filename="%lastincrementid%.txt">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:output method="text"/>

<xsl:variable name="sepstart" select="'"'"/> <!-- " field start seperator, including '' -->
<xsl:variable name="sepend" select="'",'"/> <!-- field end seperator, including '' -->

<xsl:template match="/">

<xsl:for-each select="orders/order">
<xsl:for-each select="items/item">
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(sku)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(qty)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(price)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(row_total)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../increment_id)"/><xsl:value-of select="$sepend" />

<xsl:text>&#xD;&#xA;</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
</file>
</files>

The format of %lastincrementid% is a 9 digit number such as 100007654.

The filename is currently set to be this 9 digit number BUT I want it to be only the last 4 digits, ie 7654.

Can anyone please be kind enough to show me how I go about it? I would be eternally grateful........ :-)

Last edited by Rachel Moore; August 2nd, 2016 at 11:26 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating XSLT for Xml file to output an xml file [email protected] BOOK: Beginning XSLT and XPath : Transforming XML Documents and Data 0 March 14th, 2014 12:12 PM
Problem with Magento Installation ctatvasoft PHP How-To 3 September 16th, 2011 12:38 PM
How to produce this output in XSLT 1.0 UndeadHalfOrc XSLT 1 December 9th, 2010 04:34 AM
XSLT Looks right, but no output Alderian72 XSLT 1 June 9th, 2005 08:47 AM
how to save html output of xslt to file wtalbin XSLT 2 August 15th, 2003 09:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.