Created
September 26, 2016 05:51
-
-
Save nul800sebastiaan/37dc25597a4761af4db4dd0d58f17425 to your computer and use it in GitHub Desktop.
No more @nodeTypeAlias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changes to the XML Schema | |
If you ever had to test the Document Type in XSLT, you would've probably used @nodeTypeAlias. Since the new 4.5 Schema however, this has changed. | |
Consider a Document Type with an alias of subPage. In the old Schema, the umbraco.config XML file would look something like: | |
<node id="1204" nodeTypeAlias="subPage" .... > | |
And in the new schema, nodeTypeAlias no longer exists but it is rather used as the actual XML node name. So it becomes: | |
<subPage id="1204" .....> | |
So to select the node name, we simply need to use the name() method. | |
Examples | |
Getting the Document Type for $currentPage | |
Old Schema | |
<xsl:value-of select="$currentPage/@nodeTypeAlias" /> | |
New Schema | |
<xsl:value-of select="local-name($currentPage)" /> | |
Selecting a certain document type | |
Old Schema | |
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'subPage']"> | |
New Schema | |
<xsl:for-each select="$currentPage/subPage"> | |
or | |
<xsl:for-each select="$currentPage/*"> | |
<xsl:if test="self::subPage">.......</xsl:if> | |
</xsl:for-each> | |
or if you need to test against a variable | |
<xsl:for-each select="$currentPage/*"> | |
<xsl:if test="local-name() = $subPageName">.......</xsl:if> | |
</xsl:for-each> | |
I hope I save you some hair with this post, I've gone bald trying to figure it out :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment