开发者

Can not get table in XSLT to work

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<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" 
 exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

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

<xsl:variable name="source" select="umbraco.library:GetXmlNodeById(1127)"/>
<xsl:variable name="afdelinger" select="umbraco.library:GetXmlNodeById(1128)"/>


<xsl:template match="/">
<table class="medarbejdere">

<xsl:for-each select="$afdelinger/node">
<h3><xsl:value-of select="@nodeName"/></h3>
<xsl:call-template name="medarbejdere">
<xsl:with-param name="nodeId" select="@id"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>

<xsl:template name="medarbejdere">

<xsl:param name="nodeId"/>


<xsl:for-each select="$source/node [@nodeTypeAlias='employee'] [string(data[@alias='umbracoNaviHide']) != '1']">

<xsl:variable name="preNodes">
<xsl:variable name="relatedContent" select="data[@alias='afd']" />

<xsl:variable name="nodeIds" select="umbraco.library:Split($relatedContent, ',')" />
<xsl:for-each select="$nodeIds/value">
<xsl:if test=". = $nodeId">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>

<xsl:if test="$preNodes != ''">
<tr><td>
<span>
<img>
<xsl:attribute name="src">/umbraco/imageGen.ashx?image=/<xsl:value-of select="data[@alias='imageWeb']"/>&amp;width=182&amp;height=122</xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@nodeName"/>  -  <xsl:value-of select="data[@alias='position']"/>  -  <xsl:value-of select="data[@alias='phone']"/>  -  <xsl:value-of select="data[@alias='email']"/></xsl:attribute>
</img>
<div class="info" style="padding-bottom:0px;">
<span><strong><xsl:value-of select="@nodeName"/></strong>
<em style="left:160px;top:5px;"><xsl:value-of select="data[@alias='position']"/></em>
<span class="kontaktinfo" style="left:160px;top:5px;">
<strong style="left:160px;top:5px;"><xsl:value-of select="data[@alias='phone']"/></strong>
<strong style="left:160px;top:5px;"><a href="mailto:{data[@alias='email']}"><xsl:value-of select="data[@alias='email']"/></a></strong>
</span>
</span>
</div>
</span></td>

</tr>

</xsl:if>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

I'm trying to display this table of employees - but it won't save the xslt in Umbraco? Gives this error: System.Xml.XmlException: The 'table' start tag on line 18 does not match the end tag of 'xsl:template'. Line 26, position 3.

This is the HTML i'm trying to make:

        <h3>Kundeservice</h3>
    <table class="medarbejdere">
    <tr>
      <td><span><img src="billeder/medarbejdere/jorgen.jpg" width="180" height="122" alt="Lars Meineche - Ansvarlig for Kundeservice - +45 57 66 00 05 - <a href=mailto:th@bevola.dk>th@bevola.dk</a>" />
        <div class="info"><span><strong>Lars Meineche</strong><em>Ansvarlig for Kundeservice</em> <span class="kontaktinfo"><strong>+45 57 66 00 05</strong><strong><a href=mailto:th@bevola.dk>th@bevola.dk</a></strong></span></span></div>
     </span></td>
      <td><span><img src="billeder/medarbejdere/jorgen.jpg" width="180" height="122" alt="Lars Meineche - Ansvarlig for Kundeservice - +45 57 66 00 05 - <a href=mailto:th@bevola.dk>th@bevola.dk</a>" />
        <div class="info"><span><strong>Lars Meineche</strong><em>Ansvarlig for Kundeservice</em> <span class="kontaktinfo"><strong>+45 57 66 00 05</strong><strong><a href=mailto:th@bevola.dk>th@bevola.dk</a></strong></span></span></div>
     </span></td>
      <td><span><img src="billeder/medarbejdere/jorgen.jpg" width="180" height="122" alt="Lars Meineche - Ansvarlig for Kundeservice - +45 57 66 00 05 - <a href=mailto:th@bevola.dk>th@bevola.dk</a>" />
        <div class="info"><span><strong>Lars Meineche</strong><em>Ansvarlig for Kundeservice</em> <span class="kontaktinfo"><strong>+45 57 66 00 05</strong><strong><a href=mailto:th@bevola.dk>th@bevola.dk</a></strong></span></span></div>
     </span></td>
     </tr>
     <tr>
      <td><span><img src="billeder/medarbejdere/jorgen.jpg" width="180" height="122" alt="Lars Meineche - Ansvarlig for Kundeservice - +45 57 66 00 05 - <a href=mailto:th@bevola.dk>th@bevola.dk</a>" />
        <div class="info"><span><strong>Lars Meineche</strong><em>Ansvarlig for Kundeservice</em> <span class="kontaktinfo"><strong>+45 57 66 00 05</str开发者_如何学Cong><strong><a href=mailto:th@bevola.dk>th@bevola.dk</a></strong></span></span></div>
     </span></td>
      <td></td>
      <td></td>
     </tr>
    </table>


The error makes it quite clear: you have a template in which you have a <table> start tag but no end tag for it.

In another template you have the </table> end tag. But XSLT does not output start and end tags independently. It output a node tree, consisting of nodes such as table elements. That node tree is then serialized as well-formed XML.

Trying to output start and end tags independently usually means you are trying to solve a grouping problem. There are ways to do this that XSLT can accomplish, depending on what you're trying to group by. Once you get the grouping right, you can output the whole table within the same template, and you won't have the start tag / end tag problem.

In order for us to help with how to address the grouping task, let us know what the input XML looks like, and what each table should correspond to. (Or you can google XSLT grouping.) As it is, you're producing one table start tag, and then trying to output a table end tag for every element child of $afdelinger named "node". That obviously isn't what you meant. If you want a separate table for each $afdelinger/node, why not move the <table> start tag into the "medarbejdere" template? If you only want one table total, move the </table> end tag to the end of the match="/" template.


You've opened up a table tag in your first template, but not closed it in that template. Therefore you have malformed XML which isn't valid.

<xsl:template match="/">
  <table class="medarbejdere">
    <xsl:for-each select="$afdelinger/node">
      <h3><xsl:value-of select="@nodeName"/></h3>
      <xsl:call-template name="medarbejdere">
        <xsl:with-param name="nodeId" select="@id"/>
      </xsl:call-template>
    </xsl:for-each>
  <!-- MISSING [/table] tag here -->
</xsl:template>

In addition, your child elements of a table must be one of the following:col, thead, tbody, tfoot, tr an h3 is not a valid (direct) child element of a table

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜