我需要测试一个attibute值是否以字母开头.如果不是,我将用"ID_"作为前缀,因此它将是一个有效的id类型的属性值.我目前有以下内容(测试该值不以数字开头 - 我知道这些属性值只会以字母或数字开头),但我希望有更优雅的方式:
<xsl:if test="not(starts-with(@value, '1')) and not(starts-with(@value, '2')) and not(starts-with(@value, '3')) and not(starts-with(@value, '4')) and not(starts-with(@value, '5')) and not(starts-with(@value, '6')) and not(starts-with(@value, '7')) and not(starts-with(@value, '8')) and not(starts-with(@value, '9')) and not(starts-with(@value, '0')) ">
Run Code Online (Sandbox Code Playgroud)
我正在使用XSLT 1.0.提前致谢.
在OOXML中,粗体,斜体等格式可以(并且经常令人烦恼)在多个元素之间分割,如下所示:
<w:p>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t xml:space="preserve">This is a </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t xml:space="preserve">bold </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
<w:i/>
</w:rPr>
<w:t>with a bit of italic</w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t xml:space="preserve"> </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>paragr</w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>a</w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>ph</w:t>
</w:r>
<w:r>
<w:t xml:space="preserve"> with some non-bold in it too.</w:t>
</w:r>
</w:p>
Run Code Online (Sandbox Code Playgroud)
我需要结合这些格式元素来产生这个:
<p><b>This is a mostly bold <i>with a bit of italic</i> paragraph</b> …
Run Code Online (Sandbox Code Playgroud) 我需要能够从平面树创建嵌套列表.例如,输入可能是这样的:
<root>
<h1>text</h1>
<list level="1">num1</list>
<list level="1">num2</list>
<list level="2">sub-num1</list>
<list level="2">sub-num2</list>
<list level="3">sub-sub-num1</list>
<list level="1">num3</list>
<p>text</p>
<list>num1</list>
<list>num2</list>
<h2>text</h2>
</root>
Run Code Online (Sandbox Code Playgroud)
输出应嵌套如下:
<root>
<h1>text</h1>
<ol>
<li>num1</li>
<li>num2
<ol>
<li>sub-num1</li>
<li>sub-num2
<ol>
<li>sub-sub-num1</li>
</ol>
</li>
</ol>
</li>
<li>num3</li>
</ol>
<p>text</p>
<ol>
<li>num1</li>
<li>num2</li>
</ol>
<h2>text</h2>
</root>
Run Code Online (Sandbox Code Playgroud)
我尝试了一些方法,但似乎无法得到它.任何帮助是极大的赞赏.注意:我需要使用XSLT 1.0来完成此操作.