Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Scott 5 posts 25 karma points
    Dec 10, 2009 @ 22:48
    Scott
    0

    Xml in textbox multiline, trying XSLT to html

    Using latest version of umbraco, 4.0.2.1.

    Windows Vista

    IIS 7

     

    Setup.  Have a "textbox multiline" called pagerXml, with the following xml in it:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <pages>
      <page>
        <idAndClass>SlideHoliday</idAndClass>
        <img_location>/gfx/slideheaders/holidaycoll.png</img_location>
        <img_alt>Image alt</img_alt>
        <text>
        Blah blha blh blah blah blahblah blah blah
        <br />
        <br />
        <a href="link.html">link</a>
        </text>
       </page>
    </pages>

     

    Have a XSLT file  (I'm guessing that the issue is with the line i bolded):

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
            version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:msxml="urn:schemas-microsoft-com:xslt"
            xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
            exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>

    <xsl:output method="xml"/>

    <xsl:template match="/">
        <xsl:variable name="pagesData" select="$currentPage/data [@alias = 'pagerXml']/pages/page" />
        <xsl:if test="count($pagesData) &lt; 1">
            BAD!!
        </xsl:if>
        <xsl:for-each select="$pagesData">
            <div class="panel">
                <xsl:attribute name="id">
                    <xsl:value-of select="idAndClass"/>
                </xsl:attribute>
                <div class="wrapper">
                    <div>
                        <xsl:attribute name="class">
                            <xsl:value-of select="idAndClass"/>
                        </xsl:attribute>
                        <div class="Slidetext">
                            <img width="235" height="83" class="slideheading">
                            <xsl:attribute name="src">
                                <xsl:value-of select="img_location"/>
                            </xsl:attribute>
                            <xsl:attribute name="alt">
                                <xsl:value-of select="img_alt"/>
                            </xsl:attribute>
                            </img>
                            <p class="slidep">
                                <xsl:value-of select="text"/>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

     

    Whenever i run this, it always outputs "BAD!!"  Since it doesnt find the nodes.  If i just use the XML and the XSLT outside of umbraco it works.  So i think my XSLT is working properly....

     

    What am I doing wrong?!

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 10, 2009 @ 23:18
    Chriztian Steinmeier
    0

    Hi Scott,

    When your XSLT "sees" the data it's just plain text - so it's not able to parse it like XML - maybe there's an Exslt extension function you can use to convert the text into XML for the stylesheet to transform?

    /Chriztian 

  • Paul Blair 466 posts 731 karma points
    Dec 10, 2009 @ 23:25
    Paul Blair
    1

    yes, you need to transform the text into XML. This was discussed on the old forum here

    I am currently doing something similar and the solution by Adz at the bottom of the post works well.

  • Scott 5 posts 25 karma points
    Dec 11, 2009 @ 01:03
    Scott
    0

    That worked!  Thanks!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies