Hi guys with the new format I'm getting a bit confused.. I know there are alot more instances where we'd be using * etc.. Im trying to work out how i'd do the following:
/root/descendant-or-self::* [@id = 1103 and @isDoc]/descendant::* [@isDoc]
for some reason even /root/* as a copy-of is returning nothing.. has the root element been removed?
You're probably trying this inside what's called the "root template" (<xsl:template match="/">) but that won't work, because the XML document Umbraco serves to the XSLT file is very simple - it contains a <macro> element with a childnode for every macro parameter that was sent.
The good part is that Umbraco provides the $currentPage parameter, which is a pointer to a node in the entire XML structure - so to get to the root element of the Umbraco XML, do this:
so then I'd have to traverse down again from the root element? that does make sense.. I really did think that you could just refer to root/ (i've done this previously in old umbraco)
I ended up getting the node i needed by id and traversing down but asked the root question out of interest..
Let me clarify - as soon as the "context node" is inside the XML document from Umbraco (and not the <macro> doc.) you can do the /root thing. You can change the context node using either an apply-templates instruction or a for-each instruction - it goes like this:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="currentPage" />
<!-- Up here, "/*" refers to the <macro> element -->
<xsl:template match="/">
<!-- In here, "/*" still refers to the <macro> element -->
<xsl:for-each select="$currentPage/*[@isDoc]">
<!-- In here, "/*" will get you <root> - yay! -->
</xsl:for-each>
<!-- Oh my, back to <macro> with "/*" here -->
<xsl:apply-templates select="$currentPage/bannerProperty" />
</xsl:template>
<xsl:template match="bannerProperty">
<!-- Again, we will get <root> from "/*" here -->
</xsl:template>
</xsl:stylesheet>
new xslt format help?! root?
Hi guys with the new format I'm getting a bit confused.. I know there are alot more instances where we'd be using * etc.. Im trying to work out how i'd do the following:
/root/descendant-or-self::* [@id = 1103 and @isDoc]/descendant::* [@isDoc]
for some reason even /root/* as a copy-of is returning nothing.. has the root element been removed?
Cheers, Tom
Hi Tom
What happens if you just try to make a copy-of "root/*" ? (without the beginning /)
If that does not return anything are you sure the new schema is being used?
If you're converting the XSLT files from the old schema maybe this online converter can be of use: http://blackpoint.dk/umbraco-workbench/tools/convert-xml-schema-to-45-.aspx?p=2
/Jan
Hi Tom,
You're probably trying this inside what's called the "root template" (<xsl:template match="/">) but that won't work, because the XML document Umbraco serves to the XSLT file is very simple - it contains a <macro> element with a childnode for every macro parameter that was sent.
The good part is that Umbraco provides the $currentPage parameter, which is a pointer to a node in the entire XML structure - so to get to the root element of the Umbraco XML, do this:
/Chriztian
Hi Chriztian,
so then I'd have to traverse down again from the root element? that does make sense.. I really did think that you could just refer to root/ (i've done this previously in old umbraco)
I ended up getting the node i needed by id and traversing down but asked the root question out of interest..
Thanks Jan & Chriztian
Hi Tom,
Let me clarify - as soon as the "context node" is inside the XML document from Umbraco (and not the <macro> doc.) you can do the /root thing. You can change the context node using either an apply-templates instruction or a for-each instruction - it goes like this:
/Chriztian
is working on a reply...