これは、比較を省略することによって行うことができます。
<xsl:if test='root/element'>
しかし、きれいな方法は、最終的にあなたが欲しいものを得ることがXSLを使用することです:テンプレート
だから、XML
<?xml version="1.0" encoding="utf-8"?>
<root>
<page>
<title>Franks</title>
<header>header text</header>
<bodytext>here is the body text</bodytext>
</page>
<page>
<title>Joes</title>
<footer>footer text</footer>
<bodytext>here is the body text2</bodytext>
</page>
</root>
ためのxsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="page"></xsl:apply-templates>
</xsl:template>
<xsl:template match="page">
<h1>
<xsl:value-of select="title"/>
</h1>
<p>
<xsl:value-of select="bodytext"/>
</p>
<xsl:apply-templates select="footer"/>
</xsl:template>
<xsl:template match="footer">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>
</xsl:stylesheet>
は、この方法を示していますすることができます。選択の詳細については、 w3schools xpath tutorialをご覧ください。
出典
2012-01-19 20:35:14
Nat
入力と予想出力の例を示してください。 –