It's hard to know until you've tried it, but you need to convert an XML variable into a node-set to be able to query it with XPath - it's easy to do. Here's a full sample.
System.Xml.Xsl.XslLoadException: Prefix 'make' is not defined. An error occurred at C:\inetpub\wwwroot\localhost\xslt\634568945636893025_temp.xslt(16,3). at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
- The reason for the "Prefix 'make' is not defined" error would be because you forgot to add the xmlns:make="...." just above the exclude-result-prefixes="..." line.
- The default Umbraco templates adds this namespace with the prefix msxml instead - I just like make better because the function call makes more sense to me :-) The crucial part of using namespaces is the actual namespace-URI (urn:schemas-microsoft-com:xslt).
Need help parsing an array in a for-each loop
I have the following
<xsl:variable name="Categories">
<Category Item="A" />
<Category Item="B" />
<Category Item="C" />
<Category Item="D" />
<Category Item="D" />
</xsl:variable>
I will like to use it in the following by concatenating the curent category in the for-each loop to an attribute in order to
get the value of that attribute
<xsl:for-each select="Categories">
<tr class="odd">
<td align="left" style="height:48px;">
<xsl:value-of select="umbraco.library:ReplaceLineBreaks($currentPage/* [@alias = concat('Dept', @Item)])" disable-output-escaping="yes"/>
</td>
....
</tr>
</xsl:for-each>
...
The issue I am seeing is it is not even transversing the loop
Please help
Hi Paul,
It's hard to know until you've tried it, but you need to convert an XML variable into a node-set to be able to query it with XPath - it's easy to do. Here's a full sample.
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" xmlns:make="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="umb make" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:param name="currentPage" /> <xsl:variable name="CategoriesProxy"> <Category Item="A" /> <Category Item="B" /> <Category Item="C" /> <Category Item="D" /> <Category Item="E" /> </xsl:variable> <xsl:variable name="categories" select="make:node-set($categoriesProxy)" /> <xsl:template match="/"> <xsl:for-each select="$categories/Category"> <tr class="odd"> <td align="left" style="height:48px;"> <xsl:value-of select="umbraco.library:ReplaceLineBreaks($currentPage/*[name() = concat('Dept', current()/@Item)])" disable-output-escaping="yes" /> </td> ... </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet>Note that I've changed the reference to @alias - if you're actually using the old XML schema you can change it back.
/Chriztian
I receive the following exception even after add "umb make" to the exclude-result-prefixes section.Just as shown.
exclude-result-prefixes="msxml umb make umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary umb make">
The error I receive is:
System.Xml.Xsl.XslLoadException: Prefix 'make' is not defined. An error occurred at C:\inetpub\wwwroot\localhost\xslt\634568945636893025_temp.xslt(16,3).
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
By replacing make with msxml and replacing a call to the function ReplaceLineBreaks by GetMdia for an image file. It worked!
Thanks a billion!
Hi Paul,
Just to clarify:
- The reason for the "Prefix 'make' is not defined" error would be because you forgot to add the xmlns:make="...." just above the exclude-result-prefixes="..." line.
- The default Umbraco templates adds this namespace with the prefix msxml instead - I just like make better because the function call makes more sense to me :-) The crucial part of using namespaces is the actual namespace-URI (urn:schemas-microsoft-com:xslt).
/Chriztian
is working on a reply...
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.