Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Owen Hope 119 posts 140 karma points
    Nov 17, 2010 @ 21:35
    Owen Hope
    0

    Help adding » to XSLT

    Hi

    Using Umbraco 4.5.2

    I'm trying to style the output of this XSLT

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;">
                               <!ENTITY middot "&#183;">
                               <!ENTITY laquo "&#171;">
                               <!ENTITY raquo "&#187;">
                               <!ENTITY bull "&#8226;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">

    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">
    <xsl:call-template name="drawNodes">  
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::Blog"/>  
    </xsl:call-template>
    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
      
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <ul>
    <xsl:for-each select="$parent/blogTextPage [string(./umbracoNaviHide) != '1']">
      <li class="page_item"> //I NEED TO ADD &raquo; here
      <xsl:attribute name="class">page_item page-item-<xsl:value-of select="./@id"/></xsl:attribute>
      <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
    <xsl:if test="count(./node [string(./umbracoNaviHide) != '1']) &gt; 0">   
    <xsl:call-template name="drawNodes">    
    <xsl:with-param name="parent" select="."/>    
    </xsl:call-template>  
    </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

     

    Now whenever I try and use:

    <xsl:text>&raquo;</xsl:text> or &raquo; 

    I get the following error:

    Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.

    Stumped!

    Looking around on the forums there aren't too many similar cases. Hope one of you experts pulls the rabbit outta the hat for me!

    Thanks,

    Owen

  • Jeff Grine 149 posts 189 karma points
    Nov 17, 2010 @ 21:55
    Jeff Grine
    1

    Funny, I just got that same error for the first time not 5 minutes ago. You just need to add the attribute first - so move the text between the attribute and the anchor.

  • Owen Hope 119 posts 140 karma points
    Nov 17, 2010 @ 22:26
    Owen Hope
    0

    Thank you Jeff!

     

    Owen

  • kapil 4 posts 24 karma points
    Jun 20, 2011 @ 06:38
    kapil
    0

    Hi All , I am getting the same error, my xslt is given below , i found the error on id which is bold in below xslt . I tried to put <xsl:if test="id != ''"> before this but it always return false and not control not enter in if condtion.please help.

     <xsl:for-each select="PayoutTimePeriod">                       
                                               
                                        <xsl:attribute name="id">
                                          <xsl:value-of select="compare:returnName(@id,@jointApp,@feature)"/>
                                        </xsl:attribute>
                                        <xsl:attribute name="name">
                                          <xsl:value-of select="compare:returnName(@id,@jointApp,@feature)"/>
                                        </xsl:attribute>    

                               
        </xsl:for-each>

    error is - Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.

  • kapil 4 posts 24 karma points
    Jun 21, 2011 @ 07:56
    kapil
    0

    I want to post solution of my query. i set a condition postion()=1, which bring two rows at once for my dropdown control.if i set postion()=2 , it gave the same error.

     <xsl:for-each select="PayoutTimePeriod">
                       <xsl:if test="position() = 1">
                                    <xsl:attribute name="id">
                                      <xsl:value-of select="compare:returnName(@id,@jointApp,@feature)"/>
                                    </xsl:attribute>
                                    <xsl:attribute name="name">
                                      <xsl:value-of select="compare:returnName(@id,@jointApp,@feature)"/>
                                    </xsl:attribute>                                          
                                    </xsl:if> 

     </xsl:for-each>

  • kapil 4 posts 24 karma points
    Jun 21, 2011 @ 08:02
    kapil
    0

    Hi , my other xslt also give error (Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.) on bold syntax given below, it looks like given below 

     <xsl:for-each select="Features/ProductName">
               <xsl:variable name="FileName">
        <xsl:value-of select="@fileName"/>
        </xsl:variable>
               <td align="center">

               <xsl:choose>
                             
              <xsl:when test="@fileName!=''">
       <xsl:element name="a">                                                                      
       <xsl:attribute name="onclick">OpenCarrierOutline('<xsl:value-of select="$ServerName"/>','<xsl:value-of select="$FileName"/>');</xsl:attribute>
              <xsl:attribute name="href">#</xsl:attribute>                          
       <xsl:value-of select="."/>
       </xsl:element>
       </xsl:when>
              
       </td>
         
       </xsl:for-each>

    please help

    Thanks

    kapil Gupta

    INDIA

Please Sign in or register to post replies

Write your reply to:

Draft