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 December 6th, 2016, 04:56 AM
Registered User
 
Join Date: Dec 2016
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, sorry to bother you with this.
I'm passing here just a section of my code, since it's like 300 lines in total and that is why some of tags don't match up.
I've give you as much as i have. I've check my whole website folder if there are any more xml generated there, but i can't find it.

When i was googling this, most answer were to add this code:
Code:
<xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
to mine
HTML Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>

<xsl:template match="/">


<products>
<xsl:for-each select="objects/object">
<xsl:element name="product"><xsl:attribute name="st"><xsl:value-of select="position()"/></xsl:attribute>
<xsl:element name="productID"><xsl:value-of select="sku"/></xsl:element>
<xsl:element name="productName"><xsl:value-of select="name"/></xsl:element>
<xsl:element name="url"><xsl:value-of select="product_url"/></xsl:element>
<xsl:element name="description"><xsl:value-of select="description"/></xsl:element>
</products>
</template>
but i doesn't work for me or i don't know how to implement it.

Thank you.
 
Old December 6th, 2016, 05:05 AM
Registered User
 
Join Date: Dec 2016
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, sorry to bother you with this.
I'm passing here just a section of my code, since it's like 300 lines in total and that is why some of tags don't match up.
I've give you as much as i have. I've check my whole website folder if there are any more xml generated there, but i can't find it.

When i was googling this, most answer were to add this code:
Code:
<xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
to mine
HTML Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>

<xsl:template match="/">


<products>
<xsl:for-each select="objects/object">
<xsl:element name="product"><xsl:attribute name="st"><xsl:value-of select="position()"/></xsl:attribute>
<xsl:element name="productID"><xsl:value-of select="sku"/></xsl:element>
<xsl:element name="productName"><xsl:value-of select="name"/></xsl:element>
<xsl:element name="url"><xsl:value-of select="product_url"/></xsl:element>
<xsl:element name="description"><xsl:value-of select="description"/></xsl:element>
</products>
</template>
but i doesn't work for me or i don't know how to implement it.

Thank you.
 
Old December 6th, 2016, 05:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sorry I don't think I can help you. Read some books.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 9th, 2016, 05:02 AM
Registered User
 
Join Date: Dec 2016
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
thank you for your help. I've called my friend, who had the same problem to understand me as you did, until i give him access to our Magento administration.
Here is the solution:
first part
Code:
<description>
<xsl:variable name="s_in" select="php:functionString('html_entity_decode',description)" />
    <xsl:variable name="s_temp">
        <xsl:call-template name="replace-substring">
            <xsl:with-param name="value" select="$s_in" />
            <xsl:with-param name="from" select="'&lt;/p&gt;'" />
            <xsl:with-param name="to" select="''" />
        </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="s_out">
        <xsl:call-template name="replace-substring">
            <xsl:with-param name="value" select="$s_temp" />
            <xsl:with-param name="from" select="'&lt;p&gt;'" />
            <xsl:with-param name="to" select="''" />
        </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="normalize-space($s_out)" />
</description>
Second part
Code:
<xsl:template name="replace-substring">
    <xsl:param name="value" />
    <xsl:param name="from" />
    <xsl:param name="to" />
    <xsl:choose>
        <xsl:when test="contains($value,$from)">
            <xsl:value-of select="substring-before($value,$from)" />
            <xsl:value-of select="$to" />
            <xsl:call-template name="replace-substring">
                <xsl:with-param name="value" select="substring-after($value,$from)" />
                <xsl:with-param name="from" select="$from" />
                <xsl:with-param name="to" select="$to" />
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$value" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>
Thank you again for all of your help and best regards.





Similar Threads
Thread Thread Starter Forum Replies Last Post
strip html tags with xslt smiter XSLT 4 June 19th, 2012 08:34 AM
Mutiple tags in XSLT Divya XSLT 6 April 20th, 2010 11:29 AM
xslt for tags dnandhak XSLT 4 May 23rd, 2008 05:57 AM
Replacing tags within xml using xslt patelgaurav85 XSLT 0 June 19th, 2007 12:34 PM
XSLT output with tags trinkets XSLT 22 November 14th, 2006 11:22 AM





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