bannerbannerbannerbannerbanner
Jova wiki   tid   Login/Logout

Navigation





Search the wiki
»

PoweredBy

Page History: Umbraco XML-schema and example XSLT

Compare Page Revisions

Compare revision to revision


List of revisions

« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2011/04/09 14:36


New XML-schema from version 4.5

Follows an example of the XML based on the new schema. Note that each node has been replaced with the Alias name of the node. This has ramifications on how XSLT-code has to be written.

<root id="-1">
  <Home id="1080" 
        parentID="-1" 
        level="1" 
        writerID="0" 
        creatorID="0" 
        nodeType="1066" 
        template="1051" 
        sortOrder="2" 
        createDate="2010-05-30T16:17:58" 
        updateDate="2010-05-30T16:22:54" 
        nodeName="Home" 
        urlName="home" 
        writerName="Administrator" 
        creatorName="Administrator" 
        path="-1,1080" 
        isDoc="">
     <umbracoNaviHide>0</umbracoNaviHide>
     <siteName>My Site</siteName>
     <headerText>
        <![CDATA[<p><strong>Sam Grady designed this for Warren Buckley.</strong> 
                 "This" idea was first created by the incredible Robert Brownjohn 
                 and has been copied many times since.</p>
        ]]>
     </headerText>    
    
     <Textpage id="1081" 
               parentID="1080" 
               level="2" 
               writerID="0" 
               creatorID="0" 
               nodeType="1070" 
               template="1058" 
               sortOrder="1" 
               createDate="2010-05-30T16:23:31" 
               updateDate="2010-05-30T16:24:03" 
               nodeName="About" 
               urlName="about" 
               writerName="Administrator" 
               creatorName="Administrator" 
               path="-1,1080,1081" 
               isDoc="">      
        <umbracoNaviHide>0</umbracoNaviHide>
        <headerText>
           <![CDATA[<p>This is a good place to put a service message or 
                    something to<br />help define your site or company.</p>
           ]]>
        </headerText>      
        <bodyText>
           <![CDATA[<p><strong>Lorem ipsum dolor sit amet, consectetur 
                    adipiscing elit. Aliquam ullamcorper condimentum lorem. 
                    Curabitur placerat nunc ut leo. Integer eros ligula, 
                    vestibulum at, eleifend id, dignissim vel, est.</strong></p>
           ]]>
        </bodyText>
     </Textpage>
  </Home>
</root>

Examples showing changes in XSLT

For Each child node

New version using /* to select all nodes below this and @isDoc to select documents only:
 <xsl:for-each select="$currentPage/* [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node">
</xsl:for-each>

For Each child node of a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/NewsItem">
</xsl:for-each>
Or if you have a property with the same name, use @isDoc to get document:
 <xsl:for-each select="$currentPage/NewsItem [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias='NewsItem']">
</xsl:for-each>

For Each child node excluding a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/*[not(self::NewsItem)]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias!='NewsItem']">
</xsl:for-each>

For Each child node via a selectable source

This example shows you how to list childnodes from the nodeID of the contentpicker.
New version:
 <xsl:param name="Source" select="$currentPage/mySource" />
<xsl:for-each select="umbraco.library:GetXmlNodeById($Source)/DocType">
</xsl:for-each>
Replaces old version:
<xsl:param name="Source" 
           select="umbraco.library:GetXmlNodeById($currentPage/data 
           [@alias='mySource'])" />
<xsl:for-each select="$Source/node"></xsl:for-each>

For Each node of a specfic Document Type Alias

This example walks upto the top level node and then looks through all child nodes. Expensive!
New version:
 <xsl:for-each select="$currentPage/ancestor-or-self::Home//MyDocumentType [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/ancestor-or-self::node 
                      [@nodeTypeAlias='Home']//node [@nodeTypeAlias='MyDocumentType']">
</xsl:for-each>

Using a macro parameter to get a document type property

New version:
 <xsl:value-of select="$currentPage/* [name() = $myMacroParameter and not(@isDoc)]" />

Examples showing changes in XSLT

For Each child node

New version using /* to select all nodes below this and @isDoc to select documents only:
 <xsl:for-each select="$currentPage/* [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node">
</xsl:for-each>

Examples showing changes in XSLT

For Each child node

New version using /* to select all nodes below this and @isDoc to select documents only:
 <xsl:for-each select="$currentPage/* [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node">
</xsl:for-each>

For Each child node of a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/NewsItem">
</xsl:for-each>
Or if you have a property with the same name, use @isDoc to get document:
 <xsl:for-each select="$currentPage/NewsItem [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias='NewsItem']">
</xsl:for-each>

For Each child node excluding a specfic Document Type Alias

New version:
 <xsl:for-each select="$currentPage/*[not(self::NewsItem)]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias!='NewsItem']">
</xsl:for-each>

For Each child node via a selectable source

This example shows you how to list childnodes from the nodeID of the contentpicker.
New version:
 <xsl:param name="Source" select="$currentPage/mySource" />
<xsl:for-each select="umbraco.library:GetXmlNodeById($Source)/DocType">
</xsl:for-each>
Replaces old version:
<xsl:param name="Source" 
           select="umbraco.library:GetXmlNodeById($currentPage/data 
           [@alias='mySource'])" />
<xsl:for-each select="$Source/node"></xsl:for-each>

For Each node of a specfic Document Type Alias

This example walks upto the top level node and then looks through all child nodes. Expensive!
New version:
 <xsl:for-each select="$currentPage/ancestor-or-self::Home//MyDocumentType [@isDoc]">
</xsl:for-each>
Replaces old version:
<xsl:for-each select="$currentPage/ancestor-or-self::node 
                      [@nodeTypeAlias='Home']//node [@nodeTypeAlias='MyDocumentType']">
</xsl:for-each>

Using a macro parameter to get a document type property

New version:
 <xsl:value-of select="$currentPage/* [name() = $myMacroParameter and not(@isDoc)]" />
Replaces old version:
<xsl:value-of select="$currentPage/data [@alias=$myMacroParameter]" />

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.