<RowSet>
<Row>
<Location_Long_Desc>Sydney Office</Location_Long_Desc>
<Location_Code>SYDNEY</Location_Code>
<Daypart_Long_Desc>Peak Night</Daypart_Long_Desc>
<Daypart_Code>PEANIG</Daypart_Code>
<W_20050703_Dlr>30849.3</W_20050703_Dlr>
<W_20050703_Spots>9</W_20050703_Spots>
<W_20050710_Dlr>16.35</W_20050710_Dlr>
<W_20050710_Spots>19</W_20050710_Spots>
</Row>
</RowSet>
Run Code Online (Sandbox Code Playgroud)
所以,我现在有了这个XML,我需要将W_节点转换为新的单个节点.使用这个XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:variable name="tmp" select="local-name()"/>
<xsl:choose>
<xsl:when test="starts-with($tmp, 'W_') and ends-with($tmp, '_Dlr')">
<xsl:if test="text() != ''">
<xsl:element name="Expenditure">
<xsl:element name="Period">
<xsl:value-of select="substring($tmp,3,8)"/>
</xsl:element>
<xsl:element name="Value">
<xsl:apply-templates select="node()"/>
</xsl:element>
<xsl:element name="Spots">
<xsl:apply-templates select="//RowSet/Row/W_20050703_Spots/text()"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$tmp}">
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我几乎可以到达那里,但我有几个问题.
首先,圣诞快乐!
希望没有其他人在圣诞节工作,除非他们是淘汰专家并且真的感觉到帮助我的冲动;-)
我正在使用神话般的jQuery Column Navigation Plugin以多列方式向我的用户显示数据.它在我的静态测试中运行良好,但现在将其实现到生产代码中我已经遇到了一些希望不太难以理清的东西.
它需要一个ul元素内的div,以便在列表变大时允许滚动.这里的问题是我用来创建列的foreach包装div中的每个子元素而不是整个子集合.
例如:
我应该生成看起来像这样的HTML
<div id="myTree">
<ul>
<div> <!-- required to allow scrolling within each column -->
<li>
<a>Homepage</a>
<ul>
<div>
<li><a>Contact</a></li>
<li><a>Terms & Conditions</a></li>
<li><a>Privacy information</a></li>
</div>
</ul>
</li>
<li>
<a>Contents</a>
<ul>
<div>
<li><a>Page 1</a></li>
<li>
<a>Page 2</a>
<ul>
<div>
<li><a href="./page2.1/">Page 2.1</a></li>
<li><a href="./page2.2/">Page 2.2</a></li>
</div>
</ul>
</li>
<li><a>Page 3</a></li>
</div>
</ul>
</li>
</div>
</ul>
Run Code Online (Sandbox Code Playgroud)
但使用这个淘汰代码
<div id="whatever" style="width: 100%">
<ul data-bind="foreach: { data: Column1 }">
<div>
<li><a data-bind="text: Name"></a>
<ul …Run Code Online (Sandbox Code Playgroud)