如何使用xslt到html读取此xml标记

时间:2012-03-27 14:00:32

标签: xml xslt xslt-1.0

提供一些示例如何更改此xml?在xslt html?

<define name="Procedure">
        <element name="Procedure" radlex:id="RID1559" radlex:match="Exact">
            <element name="View" radlex:id="RID10420" radlex:match="Exact">
                <optional>
                    <element name="Supine" radlex:id="RID10421" radlex:match="Exact" snomed:id="416733000">
                        <empty/>
                    </element>
                </optional>
                <optional>
                    <element name="Upright" radlex:id="RID10455" radlex:match="Exact">
                        <empty/>
                    </element>
                </optional>
                <text/>
            </element>
            <text/>
        </element>
    </define>

我想要这样的结果

-procedure 
   -View
    -Supine
      -one check box After that one text box
    -Upright 
        -one check box After that one text box

给我一​​些指导

我想得到这样的html输出我在我的xml中有这么多定义,但名字正在改变

<table>
<tr>
<td>
procedure 
</td>
</tr>
<tr>
<td>
View
</td>
</tr>
checkbox
Supine
textbox
<tr>
<td>
checkbox
Upright 
textbox
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table> 

1 个答案:

答案 0 :(得分:0)

这可能就是您所需要的:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <xsl:for-each select="define/element">
         - <xsl:value-of select="@name"/>
         <xsl:for-each select="element/optional/element">
          <input type="checkbox" name="{@name}"/> <xsl:value-of select="@name"/>

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