Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm using the multiple textstring datatype from ucomponents to create two lists.
I'm trying to output it with this XSLT but it doesnt work.. any ideas why?
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " ">]><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:template match="fordele | ulemper"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="fordele"> <li><xsl:value-of select="."/></li> </xsl:template> </xsl:stylesheet>
Here is the XML:
<root id="-1"><Forside><Tekstside id="1081" level="3" nodeName="Test" urlName="test"> <umbracoRedirect /> <overskrift>Test</overskrift> <tekst></tekst> <sidensTitel /> <sidensBeskrivelse /> <sidensNgleord /> <Faktaboks id="1113" level="4" nodeName="Det her virker" urlName="det-her-virker"> <umbracoNaviHide>1</umbracoNaviHide> - <fordele> <values> <value>Ingen emission</value> <value>Det virker bare</value> <value>Det er top nice</value> <value>Det er bare fedt</value> <value>Udstødnings</value> <value /> </values> </fordele> <ulemper> <values> <value>Giver sygdom</value> <value>Er farligt</value> <value /> </values> </ulemper> </Faktaboks></Tekstside></Forside></root>
<root id="-1">
<Forside>
<Tekstside id="1081" level="3" nodeName="Test" urlName="test"> <umbracoRedirect /> <overskrift>Test</overskrift> <tekst></tekst> <sidensTitel /> <sidensBeskrivelse /> <sidensNgleord /> <Faktaboks id="1113" level="4" nodeName="Det her virker" urlName="det-her-virker"> <umbracoNaviHide>1</umbracoNaviHide> - <fordele> <values> <value>Ingen emission</value> <value>Det virker bare</value> <value>Det er top nice</value> <value>Det er bare fedt</value> <value>Udstødnings</value> <value /> </values> </fordele> <ulemper> <values> <value>Giver sygdom</value> <value>Er farligt</value> <value /> </values> </ulemper> </Faktaboks></Tekstside></Forside></root>
This works for outputting the "fordele", but would be nice to be able to output both in same xslt file - and still have them seperated as two lists
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " ">]><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:template match="/"> <ul> <xsl:apply-templates select="$currentPage/Faktaboks/fordele" /> </ul> </xsl:template> <xsl:template match="value"> <li><xsl:value-of select="."/></li> </xsl:template> </xsl:stylesheet>
Got a little further, but got a tiny issue still - it seems to be outputting the "1" from the element when using this XSLT:
Another problem is that I cant give the UL different classes - so I guess I have to create two XSLT files for this job? :)
version="1.0" encoding="UTF-8"?>DOCTYPE xsl:stylesheet [ ENTITY nbsp " ">]><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:template match="/"> <xsl:apply-templates select="$currentPage/Faktaboks" /> xsl:template> <xsl:template match="fordele|ulemper"> <ul> <xsl:apply-templates/> ul> xsl:template> <xsl:template match="value"> <li><xsl:value-of select="."/>li> xsl:template> xsl:stylesheet>
Hi Daniel
What do you mean by the "1"?
I'm not sure...but woul'nt you somehow be able to set different class names like this...
<ul><xsl:if test="name(.) = 'fordele'"><xsl:attribute name="class">fordele</xsl:attribute></xsl:if> <xsl:if test="name(.) = 'ulemper'"> <xsl:attribute name="class">ulemper</xsl:attribute> </xsl:if>
<!-- your apply template here -->
</ul>
Does this work?
/Jan
Hi Daniel,
These templates will work - you definitely won't need two files for that; and for the separate classes - well :-)
<xsl:template match="/"> <xsl:apply-templates select="$currentPage/Faktaboks" /> </xsl:template> <xsl:template match="Faktaboks"> <xsl:apply-templates select="fordele | ulemper" /> </xsl:template> <xsl:template match="fordele | ulemper"> <ul class="{name()}"> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="value"> <li> <xsl:value-of select="."/> </li> </xsl:template>
/Chriztian
Thanks guys - Chriztian that worked totally as i wanted it :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Unordered lists XSLT wont work
I'm using the multiple textstring datatype from ucomponents to create two lists.
I'm trying to output it with this XSLT but it doesnt work.. any ideas why?
Here is the XML:
This works for outputting the "fordele", but would be nice to be able to output both in same xslt file - and still have them seperated as two lists
Got a little further, but got a tiny issue still - it seems to be outputting the "1" from the element when using this XSLT:
Another problem is that I cant give the UL different classes - so I guess I have to create two XSLT files for this job? :)
version="1.0" encoding="UTF-8"?>
DOCTYPE xsl:stylesheet [
ENTITY nbsp " ">
]>
<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:template match="/">
<xsl:apply-templates select="$currentPage/Faktaboks" />
xsl:template>
<xsl:template match="fordele|ulemper">
<ul>
<xsl:apply-templates/>
ul>
xsl:template>
<xsl:template match="value">
<li><xsl:value-of select="."/>li>
xsl:template>
xsl:stylesheet>
Hi Daniel
What do you mean by the "1"?
I'm not sure...but woul'nt you somehow be able to set different class names like this...
<ul>
<xsl:if test="name(.) = 'fordele'">
<xsl:attribute name="class">fordele</xsl:attribute>
</xsl:if>
<xsl:if test="name(.) = 'ulemper'">
<xsl:attribute name="class">ulemper</xsl:attribute>
</xsl:if>
<!-- your apply template here -->
</ul>
Does this work?
/Jan
Hi Daniel,
These templates will work - you definitely won't need two files for that; and for the separate classes - well :-)
/Chriztian
Thanks guys - Chriztian that worked totally as i wanted it :-)
is working on a reply...