Solved

What's wrong with this xslt - nothing is being displayed ...

Posted on 2011-03-16
22
601 Views
Last Modified: 2013-11-18
Please refer to this previous post for a history of this problem, which was resolved there:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XSLT/Q_26890969.html

I am now trying to apply the same solution to a different XML and XSL  file. The only difference is in the name of the tags. Nothing is being output.

I've attached both the XML and the XSL.

The XSL  should be displaying:
 the image that is within the <TaxonomyItemTeaser> tag; and
 the two paragraphs of text within the <TaxonomyItemTeaser> tag

but none of it is being displayed.

The only thing that is being displayed is "<TaxonomyItemTitle>" and "<TaxonomyItemQuickLink>"

High points because I'm under a deadline. I am trying to modify existing xsl; I have no control over the xml. I'm new at this.

Thanks.
 .
<TaxonomyData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <TaxonomyId>4294967346</TaxonomyId>
    <TaxonomyName>HR & Hiring</TaxonomyName>
    <TaxonomyImage></TaxonomyImage>
    <CategoryUrl></CategoryUrl>
    <Visible>true</Visible>
    <TaxonomyType>Content</TaxonomyType>
    <TaxonomyLanguage>1033</TaxonomyLanguage>
    <TaxonomyLanguageName>English (U.S.)</TaxonomyLanguageName>
    <TaxonomyDescription></TaxonomyDescription>
    <TaxonomyParentId>4294967341</TaxonomyParentId>
    <TaxonomyLevel>2</TaxonomyLevel>
    <TaxonomyPath>\Cost Savings\HR & Hiring</TaxonomyPath>
    <TaxonomyCreatedDate>2011-03-14T14:48:01.62</TaxonomyCreatedDate>
    <TaxonomyItemCount>1</TaxonomyItemCount>
    <TaxonomyHasChildren>false</TaxonomyHasChildren>
    <TemplateId>0</TemplateId>
    <TemplateName></TemplateName>
    <TemplateInherited>true</TemplateInherited>
    <TemplateInheritedFrom>4294967341</TemplateInheritedFrom>
    <TaxonomyItems>
        <TaxonomyItemData>
            <TaxonomyId>4294967346</TaxonomyId>
            <ContentType></ContentType>
            <TaxonomyItemStatus>Approved</TaxonomyItemStatus>
            <ContentSubType>PageBuilderData</ContentSubType>
            <TaxonomyLanguage>1033</TaxonomyLanguage>
            <TaxonomyItemId>4294967391</TaxonomyItemId>
            <TaxonomyItemLanguage>1033</TaxonomyItemLanguage>
            <TaxonomyItemType>1</TaxonomyItemType>
            <TaxonomyItemAddedUser>0</TaxonomyItemAddedUser>
            <TaxonomyItemTitle>Test Program</TaxonomyItemTitle>
            <TaxonomyItemTeaser>
                <p>
                    <img src="/uploadedImages/CCA/Content/Forms/ADP_logo.gif" alt="ADP logo" title="ADP logo" />
                </p>

                <p> </p>
                <p> </p>
                <p>
                    This is a <strong>test program</strong> using the new template that gets the correct left-hand menu (<em>a list of categories</em>).
                </p>
                <p>This would be second paragraph.</p>
                <p> </p>
            </TaxonomyItemTeaser>
            <TaxonomyItemQuickLink>/Test_Program.aspx</TaxonomyItemQuickLink>
            <TaxonomyItemEditorLastName>Shea</TaxonomyItemEditorLastName>
            <TaxonomyItemEditorFirstName>Alicia</TaxonomyItemEditorFirstName>
            <TaxonomyItemDateModified>3/16/2011 11:24:05 AM</TaxonomyItemDateModified>
            <TaxonomyItemDisplayDateModified>3/16/2011 11:24:05 AM</TaxonomyItemDisplayDateModified>
            <TaxonomyItemDisplayDateCreated>3/15/2011 3:23:27 PM</TaxonomyItemDisplayDateCreated>
            <TaxonomyItemThumbnail></TaxonomyItemThumbnail>
            <TaxonomyItemImage></TaxonomyItemImage>
            <TaxonomyItemHtml>
                <PageData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="PB">
                    <IsMasterLayout>false</IsMasterLayout>
                    <masterID>0</masterID>
                    <pageID>4294967391</pageID>
                    <languageID>1033</languageID>
                    <title>Test Program</title>
                    <Widgets>
                        <WidgetData>
                            <ID xmlns="PW">40</ID>
                            <ControlURL xmlns="PW">ExternalContent.ascx</ControlURL>
                            <ColumnID xmlns="PW">0</ColumnID>
                            <Order xmlns="PW">0</Order>
                            <Minimized xmlns="PW">false</Minimized>
                            <Settings xmlns="PW">&lt;ArrayOfDataStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;dataStore&gt;&lt;Property&gt;ContentID&lt;/Property&gt;&lt;Value xsi:type="xsd:long"&gt;10737418633&lt;/Value&gt;&lt;TypeName&gt;System.Int64&lt;/TypeName&gt;&lt;AssemblyAndType&gt;System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/AssemblyAndType&gt;&lt;/dataStore&gt;&lt;dataStore&gt;&lt;Property&gt;FolderPath&lt;/Property&gt;&lt;Value xsi:type="xsd:string"&gt;0&lt;/Value&gt;&lt;TypeName&gt;System.String&lt;/TypeName&gt;&lt;AssemblyAndType&gt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/AssemblyAndType&gt;&lt;/dataStore&gt;&lt;/ArrayOfDataStore&gt;</Settings>
                            <DropID>Center</DropID>
                            <ColumnGuid>00000000-0000-0000-0000-000000000000</ColumnGuid>
                            <ChildColumns />
                            <KeyValues />
                        </WidgetData>
                        <WidgetData>
                            <ID xmlns="PW">10</ID>
                            <ControlURL xmlns="PW">ContentBlock.ascx</ControlURL>
                            <ColumnID xmlns="PW">0</ColumnID>
                            <Order xmlns="PW">0</Order>
                            <Minimized xmlns="PW">false</Minimized>
                            <Settings xmlns="PW">&lt;ArrayOfDataStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;dataStore&gt;&lt;Property&gt;ContentBlockId&lt;/Property&gt;&lt;Value xsi:type="xsd:long"&gt;4294967349&lt;/Value&gt;&lt;TypeName&gt;System.Int64&lt;/TypeName&gt;&lt;AssemblyAndType&gt;System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/AssemblyAndType&gt;&lt;/dataStore&gt;&lt;dataStore&gt;&lt;Property&gt;IsGoogleMultivariate&lt;/Property&gt;&lt;Value xsi:type="xsd:boolean"&gt;false&lt;/Value&gt;&lt;TypeName&gt;System.Boolean&lt;/TypeName&gt;&lt;AssemblyAndType&gt;System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/AssemblyAndType&gt;&lt;/dataStore&gt;&lt;dataStore&gt;&lt;Property&gt;GoogleSectionName&lt;/Property&gt;&lt;Value xsi:type="xsd:string"&gt;&lt;/Value&gt;&lt;TypeName&gt;System.String&lt;/TypeName&gt;&lt;AssemblyAndType&gt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/AssemblyAndType&gt;&lt;/dataStore&gt;&lt;/ArrayOfDataStore&gt;</Settings>
                            <DropID>RightTop</DropID>
                            <ColumnGuid>00000000-0000-0000-0000-000000000000</ColumnGuid>
                            <ChildColumns />
                            <KeyValues />
                        </WidgetData>
                    </Widgets>
                    <Zones>
                        <DropZoneData>
                            <DropZoneID>LeftBottom</DropZoneID>
                            <isMasterZone>false</isMasterZone>
                            <Columns>
                                <ColumnData>
                                    <Guid>00000000-0000-0000-0000-000000000000</Guid>
                                    <Display>true</Display>
                                    <columnID>0</columnID>
                                    <width>100</width>
                                    <unit>percent</unit>
                                </ColumnData>
                            </Columns>
                        </DropZoneData>
                        <DropZoneData>
                            <DropZoneID>Center</DropZoneID>
                            <isMasterZone>false</isMasterZone>
                            <Columns>
                                <ColumnData>
                                    <Guid>00000000-0000-0000-0000-000000000000</Guid>
                                    <Display>true</Display>
                                    <columnID>0</columnID>
                                    <width>100</width>
                                    <unit>percent</unit>
                                </ColumnData>
                            </Columns>
                        </DropZoneData>
                        <DropZoneData>
                            <DropZoneID>CenterBottom</DropZoneID>
                            <isMasterZone>false</isMasterZone>
                            <Columns>
                                <ColumnData>
                                    <Guid>00000000-0000-0000-0000-000000000000</Guid>
                                    <Display>true</Display>
                                    <columnID>0</columnID>
                                    <width>0</width>
                                    <unit>pixels</unit>
                                </ColumnData>
                            </Columns>
                        </DropZoneData>
                        <DropZoneData>
                            <DropZoneID>RightTop</DropZoneID>
                            <isMasterZone>false</isMasterZone>
                            <Columns>
                                <ColumnData>
                                    <Guid>00000000-0000-0000-0000-000000000000</Guid>
                                    <Display>true</Display>
                                    <columnID>0</columnID>
                                    <width>100</width>
                                    <unit>percent</unit>
                                </ColumnData>
                            </Columns>
                        </DropZoneData>
                        <DropZoneData>
                            <DropZoneID>RightBottom</DropZoneID>
                            <isMasterZone>false</isMasterZone>
                            <Columns>
                                <ColumnData>
                                    <Guid>00000000-0000-0000-0000-000000000000</Guid>
                                    <Display>true</Display>
                                    <columnID>0</columnID>
                                    <width>100</width>
                                    <unit>percent</unit>
                                </ColumnData>
                            </Columns>
                        </DropZoneData>
                    </Zones>
                </PageData>
            </TaxonomyItemHtml>
            <TaxonomyItemObjectType>0</TaxonomyItemObjectType>
            <TaxonomyItemFilePath>Test_Program.aspx</TaxonomyItemFilePath>
            <TaxonomyItemFolderId>119</TaxonomyItemFolderId>
            <TaxonomyItemGoLiveDate>0001-01-01T00:00:00</TaxonomyItemGoLiveDate>
            <TaxonomyItemEndDate>0001-01-01T00:00:00</TaxonomyItemEndDate>
        </TaxonomyItemData>
    </TaxonomyItems>
    <Taxonomy></Taxonomy>
    <FolderId>-1</FolderId>
</TaxonomyData>

Open in new window

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xhtml"/>



    <xsl:template match="TaxonomyData">
        <h1 class="nps_costsavings">
            Category: <xsl:value-of select="TaxonomyName"/>
        </h1>
        <p>
            <em>These are the cost savings programs in this category. If you don't see any programs listed here, it means there are none in this category that are available to you.</em>
        </p>
       
       <!-- <xsl:copy-of select="."/> -->

        <xsl:apply-templates select=".//TaxonomyItems" >
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="TaxonomyItems">
        <ul class="nps_programs">
            <xsl:apply-templates select="TaxonomyItemData" />
        </ul>
    </xsl:template>

    <xsl:template match="TaxonomyItemData">
        <li>
            <div class="nps_program_summary_top">
            </div>

            <div class="nps_program_summary">
                <table>
                    <tr>
                        <td class="nps_program_image_container">
                            <img class="nps_program_image">
                                <xsl:attribute name="src">
                                    <xsl:value-of select="TaxonomyItemTeaser/p/img//@src"/>
                                </xsl:attribute>
                                <xsl:attribute name="alt">
                                    <xsl:text>Program Logo</xsl:text>
                                </xsl:attribute>
                            </img>
                        </td>
                        <td class="nps_program_summary">
                            <h2>
                                <xsl:value-of select="TaxonomyItemTitle"/>
                            </h2>
                            <p>
                                <!-- omits empty <p> tags and also the <img> tag within <p> tag (from EE) -->
                                <xsl:apply-templates select="TaxonomyItemTeaser/p[normalize-space(translate(., '&#160;', ''))]" />
                            </p>
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="TaxonomyItemQuickLink"/>
                                </xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="TaxonomyItemTitle"/>
                                </xsl:attribute>
                                <xsl:text>Learn More</xsl:text>
                            </a>
                        </td>
                    </tr>
                </table>

            </div>
            <div class="nps_program_summary_bot">
            </div>
        </li>
    </xsl:template>

   <xsl:template match="TaxonomyItemTeaser/p">
        <xsl:copy-of select="." />
    </xsl:template>
   
    
</xsl:stylesheet>

Open in new window

0
Comment
Question by:alicia1234
  • 11
  • 10
22 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35152007
If I apply this XSLT to the XML (after correction because '&' needs escaping)
This is what I get.
I am afraid that something happens after the XSLT,
or that you are not showing all of it
<h1 class="nps_costsavings">
   Category: HR &amp; Hiring
</h1>
<p>
   <em>These are the cost savings programs in this category. If you don't see any programs listed here, it means there are none in
      this category that are available to you.
   </em>
</p>
<ul class="nps_programs">
   <li>
      <div class="nps_program_summary_top"></div>
      <div class="nps_program_summary">
         <table>
            <tr>
               <td class="nps_program_image_container">
                  <img class="nps_program_image" src="/uploadedImages/CCA/Content/Forms/ADP_logo.gif"
                       alt="Program Logo"></img>
               </td>
               <td class="nps_program_summary">
                  <h2>Test Program</h2>
                  <p>
                     <p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                        This is a 
                        <strong>test program</strong> using the new template that gets the correct left-hand menu (
                        <em>a list of categories</em>).
                        
                     </p>
                     <p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:xsd="http://www.w3.org/2001/XMLSchema">This would be second paragraph.</p>
                  </p>
                  <a href="/Test_Program.aspx" title="Test Program">Learn More</a>
               </td>
            </tr>
         </table>
      </div>
      <div class="nps_program_summary_bot"></div>
   </li>
</ul>

Open in new window

0
 

Author Comment

by:alicia1234
ID: 35152656
Thank you Gertrone.
I am indeed showing all of the xslt. I don't have control over the XML per se, but I was able to change "HR & Hiring" to "HR and Hiring" to avoid that problem. It did not help me though.
Still I get nothing.
This is part of the Ektron CMS - recall that we had some problems with this before where the XML wasn't "really" XML but was text instead. I fear the same thing is happening here because I am using the same "Ektron server control". With the previous problem, you created strings that we then used instead of the XML tags.


See previous problem here
0
 
LVL 18

Expert Comment

by:zc2
ID: 35152812
I see, the XSLT declaration states the XSLT version 2.0

I don't know can that be a reason on not, but could you try to change the first two lines from

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xhtml"/>

to

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="html"/>

and then see if the output changes?

0
 

Author Comment

by:alicia1234
ID: 35152931
thanks zc2 ...
that does not make any difference.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35154004
so, let's use the same thrick as before then.

Can you replace the XSLT with the below one and show us the result you get?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35154180
let's go from the suspicion that indeed your <TaxonomyItemTeaser> is a text block instead of a html block
Can you show me the result of this stylesheet?
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xhtml"/>
    
    
    
    <xsl:template match="TaxonomyData">
        <h1 class="nps_costsavings">
            Category: <xsl:value-of select="TaxonomyName"/>
        </h1>
        <p>
            <em>These are the cost savings programs in this category. If you don't see any programs listed here, it means there are none in this category that are available to you.</em>
        </p>
        
        <!-- <xsl:copy-of select="."/> -->
        
        <xsl:apply-templates select=".//TaxonomyItems" >
        </xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="TaxonomyItems">
        <ul class="nps_programs">
            <xsl:apply-templates select="TaxonomyItemData" />
        </ul>
    </xsl:template>
    
    <xsl:template match="TaxonomyItemData">
        <li>
            <div class="nps_program_summary_top">
            </div>
            
            <div class="nps_program_summary">
                <table>
                    <tr>
                        <td class="nps_program_image_container">
                            <img class="nps_program_image">
                                <xsl:attribute name="src">
                                    <xsl:value-of select="TaxonomyItemTeaser/p/img//@src"/>
                                </xsl:attribute>
                                <xsl:attribute name="alt">
                                    <xsl:text>Program Logo</xsl:text>
                                </xsl:attribute>
                            </img>
                        </td>
                        <td class="nps_program_summary">
                            <h2>
                                <xsl:value-of select="TaxonomyItemTitle"/>
                            </h2>
                            <p>
                                <!-- omits empty <p> tags and also the <img> tag within <p> tag (from EE) -->
                                <xsl:apply-templates select="TaxonomyItemTeaser" />
                            </p>
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="TaxonomyItemQuickLink"/>
                                </xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="TaxonomyItemTitle"/>
                                </xsl:attribute>
                                <xsl:text>Learn More</xsl:text>
                            </a>
                        </td>
                    </tr>
                </table>
                
            </div>
            <div class="nps_program_summary_bot">
            </div>
        </li>
    </xsl:template>
    
<!--    <xsl:template match="TaxonomyItemTeaser">
        <xsl:apply-templates select="p[normalize-space(translate(., '&#160;', ''))]"></xsl:apply-templates>
    </xsl:template>
-->    
    <xsl:template match="TaxonomyItemTeaser">
        <xsl:value-of select="translate(., '&lt;&gt;', '[]')"/>
    </xsl:template>
    
    
</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35154646
And here would be the solution if all were text nodes.
I assumed XSLT1, because Ektron has msxml
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xhtml"/>
    
    
    
    <xsl:template match="TaxonomyData">
        <h1 class="nps_costsavings">
            Category: <xsl:value-of select="TaxonomyName"/>
        </h1>
        <p>
            <em>These are the cost savings programs in this category. If you don't see any programs listed here, it means there are none in this category that are available to you.</em>
        </p>
        
        <!-- <xsl:copy-of select="."/> -->
        
        <xsl:apply-templates select=".//TaxonomyItems" >
        </xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="TaxonomyItems">
        <ul class="nps_programs">
            <xsl:apply-templates select="TaxonomyItemData" />
        </ul>
    </xsl:template>
    
    <xsl:template match="TaxonomyItemData">
        <li>
            <div class="nps_program_summary_top">
            </div>
            
            <div class="nps_program_summary">
                <table>
                    <tr>
                        <td class="nps_program_image_container">
                            <img class="nps_program_image">
                                <xsl:attribute name="src">
                                    <xsl:value-of select="TaxonomyItemTeaser/p/img//@src"/>
                                </xsl:attribute>
                                <xsl:attribute name="alt">
                                    <xsl:text>Program Logo</xsl:text>
                                </xsl:attribute>
                            </img>
                        </td>
                        <td class="nps_program_summary">
                            <h2>
                                <xsl:value-of select="TaxonomyItemTitle"/>
                            </h2>
                            <!-- omits empty <p> tags and also the <img> tag within <p> tag (from EE) -->
                            <xsl:apply-templates select="TaxonomyItemTeaser" />
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="TaxonomyItemQuickLink"/>
                                </xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="TaxonomyItemTitle"/>
                                </xsl:attribute>
                                <xsl:text>Learn More</xsl:text>
                            </a>
                        </td>
                    </tr>
                </table>
                
            </div>
            <div class="nps_program_summary_bot">
            </div>
        </li>
    </xsl:template>
    
<!--    <xsl:template match="TaxonomyItemTeaser">
        <xsl:apply-templates select="p[normalize-space(translate(., '&#160;', ''))]"></xsl:apply-templates>
    </xsl:template>
-->    
    <xsl:template match="TaxonomyItemTeaser">
        <xsl:call-template name="process-teaser">
            <xsl:with-param name="str" select="."/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template name="process-teaser">
        <xsl:param name="str"/>
        <xsl:choose>
            <xsl:when test="contains($str, '&lt;p>')">
                <xsl:variable name="p-content" select="normalize-space(translate(substring-before(substring-after($str, '&lt;p>'), '&lt;/p>'),'&#160;', ''))"/>
                <xsl:value-of select="substring-before($str, '&lt;p>')"/>
                <xsl:choose>
                    <xsl:when test="$p-content and not(starts-with($p-content, '&lt;img'))">
                        <p><xsl:value-of select="$p-content" disable-output-escaping="yes"/></p>
                    </xsl:when>
                </xsl:choose>
                <xsl:call-template name="process-teaser">
                    <xsl:with-param name="str" select="substring-after($str, '&lt;/p>')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$str"/>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 35154707
And all in the same assumption...
this one puls out the image too
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xhtml"/>
    
    
    
    <xsl:template match="TaxonomyData">
        <h1 class="nps_costsavings">
            Category: <xsl:value-of select="TaxonomyName"/>
        </h1>
        <p>
            <em>These are the cost savings programs in this category. If you don't see any programs listed here, it means there are none in this category that are available to you.</em>
        </p>
        
        <!-- <xsl:copy-of select="."/> -->
        
        <xsl:apply-templates select=".//TaxonomyItems" >
        </xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="TaxonomyItems">
        <ul class="nps_programs">
            <xsl:apply-templates select="TaxonomyItemData" />
        </ul>
    </xsl:template>
    
    <xsl:template match="TaxonomyItemData">
        <li>
            <div class="nps_program_summary_top">
            </div>
            
            <div class="nps_program_summary">
                <table>
                    <tr>
                        <td class="nps_program_image_container">
                            <img class="nps_program_image">
                                <xsl:variable name="image-tag" select="substring-before(substring-after(TaxonomyItemTeaser, '&lt;img'), '>')"/>
                                <xsl:variable name="src-raw-value" select="substring-after($image-tag, 'src=')"/>
                                <xsl:variable name="attribute-seperator" select="substring($src-raw-value, 1, 1)"/>
                                <xsl:variable name="src-attribute" select="substring-before(substring-after($src-raw-value, $attribute-seperator), $attribute-seperator)"/>
                                <xsl:attribute name="src">
                                    <xsl:value-of select="$src-attribute"/>
                                </xsl:attribute>
                                <xsl:attribute name="alt">
                                    <xsl:text>Program Logo</xsl:text>
                                </xsl:attribute>
                            </img>
                        </td>
                        <td class="nps_program_summary">
                            <h2>
                                <xsl:value-of select="TaxonomyItemTitle"/>
                            </h2>
                            <!-- omits empty <p> tags and also the <img> tag within <p> tag (from EE) -->
                            <xsl:apply-templates select="TaxonomyItemTeaser" />
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="TaxonomyItemQuickLink"/>
                                </xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="TaxonomyItemTitle"/>
                                </xsl:attribute>
                                <xsl:text>Learn More</xsl:text>
                            </a>
                        </td>
                    </tr>
                </table>
                
            </div>
            <div class="nps_program_summary_bot">
            </div>
        </li>
    </xsl:template>
    
<!--    <xsl:template match="TaxonomyItemTeaser">
        <xsl:apply-templates select="p[normalize-space(translate(., '&#160;', ''))]"></xsl:apply-templates>
    </xsl:template>
-->    
    <xsl:template match="TaxonomyItemTeaser">
        <xsl:call-template name="process-teaser">
            <xsl:with-param name="str" select="."/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template name="process-teaser">
        <xsl:param name="str"/>
        <xsl:choose>
            <xsl:when test="contains($str, '&lt;p>')">
                <xsl:variable name="p-content" select="normalize-space(translate(substring-before(substring-after($str, '&lt;p>'), '&lt;/p>'),'&#160;', ''))"/>
                <xsl:value-of select="substring-before($str, '&lt;p>')"/>
                <xsl:choose>
                    <xsl:when test="$p-content and not(starts-with($p-content, '&lt;img'))">
                        <p><xsl:value-of select="$p-content" disable-output-escaping="yes"/></p>
                    </xsl:when>
                </xsl:choose>
                <xsl:call-template name="process-teaser">
                    <xsl:with-param name="str" select="substring-after($str, '&lt;/p>')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$str"/>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:alicia1234
ID: 35156114
Gertrone: You have suggested four different variations for the xsl file. I am doing them in order.

The first one:

Displays the XML on the screen. I did a view source and copy/pasted it into an xml file in Visual Studio so it is formatted. That file is attached here.


XMLFile2.xml
0
 

Author Comment

by:alicia1234
ID: 35156154
Here is a screen shot from the second suggestion (I've added a couple more items to the taxonomy since yesterday ...)


Screen-shot-second-suggestion.png
0
 

Author Comment

by:alicia1234
ID: 35156190
Screen shot from third suggestion ...


Screen-shot-third-suggestion.png
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35156195
yeah, I could not be stopped :-)
The second one proves it all.... it are indeed txt nodes, not child elements
(good catch, thinking about the Ektron issue again)

So, well that means that the third and fourth  stylesheet are on the right track.
You can simply use the fourth one, it will do what you need it to do
0
 

Author Comment

by:alicia1234
ID: 35156210
Screen shot from fourth suggestion .... YAY!!!!  .... THANK YOU!!!!


Screen-shot-fourth-suggestion.png
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35156237
welcome
0
 

Author Comment

by:alicia1234
ID: 35156254
Gertone - I cannot thank you enough! Thanks for sticking by me on this one. I just knew it had to be similar to that previous problem.
;-)
0
 

Author Closing Comment

by:alicia1234
ID: 35156257
Excellent!
0
 

Author Comment

by:alicia1234
ID: 35156432
Oops ...one small problem ...
If there is a space before (or after?) the image tag, the image gets displayed twice ... once with the separate img tag in the xsl, and once as part of the paragraph ... so it's not getting stripped out of the <p> tag. Because of the horrible editor in Ektron, extra spaces get put in all over the place (mostly between consecutive tags) and the user has no control over it.
Do you have a slight "tweak" for this anomaly?
Thanks.

<p>&#160;<img title="Vendor logo" alt="Vendor logo" src="/uploadedImages/CCA/Content/Forms/Vendor_Logo.png" />&#160;</p>
<p>Lots of great discounts from this vendor</p>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35156492
I assumed there was only one img and that it was at the beginning of the p

line 90
                    <xsl:when test="$p-content and not(starts-with($p-content, '&lt;img'))">

should be
                    <xsl:when test="$p-content and not(contains($p-content, '&lt;img'))">

it will work
0
 

Author Comment

by:alicia1234
ID: 35156523
Perfect! Thank you again. ;-)
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35156535
welcome
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35157481
Hi Alicia,

Try to stop me!

I figured out that also the &#160; is not a character but an expanded string in the string version of the html,
so my stylesheet would not work if you had a "&#160;" in there
(I started looking into it since I was intrigued by the fact that the image stuff did not work)

You need some further recursive processing for getting rid of that character too
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xhtml"/>
    
    
    
    <xsl:template match="TaxonomyData">
        <h1 class="nps_costsavings">
            Category: <xsl:value-of select="TaxonomyName"/>
        </h1>
        <p>
            <em>These are the cost savings programs in this category. If you don't see any programs listed here, it means there are none in this category that are available to you.</em>
        </p>
        
        <!-- <xsl:copy-of select="."/> -->
        
        <xsl:apply-templates select=".//TaxonomyItems" >
        </xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="TaxonomyItems">
        <ul class="nps_programs">
            <xsl:apply-templates select="TaxonomyItemData" />
        </ul>
    </xsl:template>
    
    <xsl:template match="TaxonomyItemData">
        <li>
            <div class="nps_program_summary_top">
            </div>
            
            <div class="nps_program_summary">
                <table>
                    <tr>
                        <td class="nps_program_image_container">
                            <img class="nps_program_image">
                                <xsl:variable name="image-tag" select="substring-before(substring-after(TaxonomyItemTeaser, '&lt;img'), '>')"/>
                                <xsl:variable name="src-raw-value" select="substring-after($image-tag, 'src=')"/>
                                <xsl:variable name="attribute-seperator" select="substring($src-raw-value, 1, 1)"/>
                                <xsl:variable name="src-attribute" select="substring-before(substring-after($src-raw-value, $attribute-seperator), $attribute-seperator)"/>
                                <xsl:attribute name="src">
                                    <xsl:value-of select="$src-attribute"/>
                                </xsl:attribute>
                                <xsl:attribute name="alt">
                                    <xsl:text>Program Logo</xsl:text>
                                </xsl:attribute>
                            </img>
                        </td>
                        <td class="nps_program_summary">
                            <h2>
                                <xsl:value-of select="TaxonomyItemTitle"/>
                            </h2>
                            <!-- omits empty <p> tags and also the <img> tag within <p> tag (from EE) -->
                            <xsl:apply-templates select="TaxonomyItemTeaser" />
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="TaxonomyItemQuickLink"/>
                                </xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="TaxonomyItemTitle"/>
                                </xsl:attribute>
                                <xsl:text>Learn More</xsl:text>
                            </a>
                        </td>
                    </tr>
                </table>
                
            </div>
            <div class="nps_program_summary_bot">
            </div>
        </li>
    </xsl:template>
    
<!--    <xsl:template match="TaxonomyItemTeaser">
        <xsl:apply-templates select="p[normalize-space(translate(., '&#160;', ''))]"></xsl:apply-templates>
    </xsl:template>
-->    
    <xsl:template match="TaxonomyItemTeaser">
        <xsl:call-template name="process-teaser">
            <xsl:with-param name="str" select="."/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template name="process-teaser">
        <xsl:param name="str"/>
        <xsl:choose>
            <xsl:when test="contains($str, '&lt;p>')">
                <xsl:variable name="p-content-prep">
                    <xsl:call-template name="strip-string">
                        <xsl:with-param name="string-to-strip" select="'&amp;#160;'"/>
                        <xsl:with-param name="str" select="substring-before(substring-after($str, '&lt;p>'), '&lt;/p>')"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:variable name="p-content" select="normalize-space($p-content-prep)"/>
                <xsl:value-of select="substring-before($str, '&lt;p>')"/>
                 <xsl:choose>
                    <xsl:when test="$p-content and not(contains($p-content, '&lt;img'))">
                        <p><xsl:value-of select="$p-content" disable-output-escaping="yes"/></p>
                    </xsl:when>
                </xsl:choose>
                <xsl:call-template name="process-teaser">
                    <xsl:with-param name="str" select="substring-after($str, '&lt;/p>')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$str"/>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
    
    <xsl:template name="strip-string">
        <xsl:param name="str"/>
        <xsl:param name="string-to-strip"/>
        <xsl:choose>
            <xsl:when test="contains($str, $string-to-strip)">
                <xsl:value-of select="substring-before($str, $string-to-strip)"/>
                <xsl:call-template name="strip-string">
                    <xsl:with-param name="string-to-strip" select="$string-to-strip"/>
                    <xsl:with-param name="str" select="substring-after($str, $string-to-strip)"></xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$str"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:alicia1234
ID: 35157733
I would never try to stop you! ;-) You are a big help and I learn alot from you.
The most recent  code works just fine, too.
Thank you again!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now