Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
No more @nodeTypeAlias
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
You can’t perform that action at this time.