国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

javascript xml xsl取值及數(shù)據(jù)修改第1/2頁

瀏覽:310日期:2022-06-04 13:54:17
1.example.xml--主要數(shù)據(jù)文件
<?xml version="1.0" encoding="UTF-8"?>

<?xml:stylesheet type="text/xsl" href="example.xsl"?>

<projects id="1">
    <project title="一級標題1" index="1">
        <items isTrunk="false" title="二級標題1.1" id="items_1">
            <result type="2">1</result>
            <officer><![CDATA[]]></officer>
            <classified>1</classified>
            <eligibility>0</eligibility>
            <remark></remark>
        </items>
        <items isTrunk="false" title="二級標題1.2" id="items_2">
            <result type="2">3</result>
            <officer><![CDATA[]]></officer>
            <classified>1</classified>
            <eligibility>0</eligibility>
        </items>
    </project>
    <project title="一級標題2" index="2">
        <items isTrunk="false" title="二級標題2.1" id="items_3">
            <result type="3">3</result>
            <officer><![CDATA[]]></officer>
            <classified>1</classified>
            <eligibility>0</eligibility>
        </items>
        <items isTrunk="true" title="二級標題2.2">
            <item title="三級標題2.2.1" id="item_1">
                <result type="1">2</result>
                <officer><![CDATA[居然是亂碼]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
            <item title="三級標題2.2.2" id="item_2">
                <result type="1">3</result>
                <officer><![CDATA[<><>]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
        </items>            
        <items isTrunk="true" title="二級標題2.3">
            <item title="三級標題2.3.1" id="item_3">
                <result type="2">1</result>
                <officer><![CDATA[]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
            <item title="三級標題2.3.2" id="item_4">
                <result type="2">1</result>
                <officer><![CDATA[]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
        </items>            
    </project>
    <project title="一級標題3" index="3">
        <items isTrunk="false" title="二級標題3.1" id="items_4">
            <result type="4" units="元">25345</result>
            <officer><![CDATA[sinoly]]></officer>
            <classified>1</classified>
            <eligibility>0</eligibility>
        </items>
        <items isTrunk="false" title="二級標題3.2" id="items_5">
            <result type="4" units="元">9865764</result>
            <officer><![CDATA[]]></officer>
            <classified>1</classified>
            <eligibility>0</eligibility>
        </items>
        <items isTrunk="false" title="二級標題3.3" id="items_6">
            <result type="2">0</result>
            <officer><![CDATA[]]></officer>
            <classified>1</classified>
            <eligibility>0</eligibility>
        </items>
        <items isTrunk="true" title="二級標題3.4">
            <item title="三級標題3.4.1" id="item_5">
                <result type="1">0</result>
                <officer><![CDATA[]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
            <item title="三級標題3.4.2" id="item_6">
                <result type="1">0</result>
                <officer><![CDATA[]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
            <item title="三級標題3.4.3" id="item_7">
                <result type="1">0</result>
                <officer><![CDATA[]]></officer>
                <classified>1</classified>
                <eligibility>0</eligibility>
            </item>
        </items>
    </project>
</projects>
2.example.xsl--樣式文件,很方便的取到xml數(shù)據(jù)

<?xml version="1.0" encoding="gb2312"?>

<xsl:stylesheet version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!--根模板-->    
    <xsl:output method="xml"/>

    <xsl:template match="/">    
        <xsl:apply-templates select="projects/project"/>
        <h6>
            <button type="submit" class="btn1_mouseout" onmouseover="this.className="btn1_mouseover"" onmouseout="this.className="btn1_mouseout"" title="提交"> 下一步</button>
        </h6>
    </xsl:template>

    <!--主題模板-->
    <xsl:template match="project">
        <TABLE border="0" cellspacing="0" cellpadding="0" class="table">
            <tr>
                <td colspan="5" align="center" class="tright">
                    <h2>
                        <xsl:number value="position()" format="一、"/><xsl:value-of select="@title"/>
                    </h2>
                </td>
            </tr>
            <xsl:apply-templates select="items"/>
        </TABLE>
        <BR/>
    </xsl:template>

    <!--一級題干模板-->
    <xsl:template match="items">
        <tr>
            <td colspan="2" class="tright">
                <xsl:number value="position()" format="1."/><xsl:value-of select="@title"/>
            </td>
            <xsl:choose>
                <xsl:when test="@isTrunk[.="false"]">
                    <xsl:apply-templates select="result"/>
                    <xsl:apply-templates select="officer"/>
                </xsl:when>
                <xsl:otherwise>
                    <td colspan="3" class="tright" style="color:blue;font-weight:bolder">
                        注意以下幾點
                    </td>
                    <xsl:apply-templates select="item"/>
                </xsl:otherwise>
            </xsl:choose>
        </tr>
    </xsl:template>

        <!--二級題干模板-->
    <xsl:template match="item">

      <tr>
        <td class="tright" style="padding-left:20px" colspan="2">
            <h4><xsl:number value="position()" format="(a)."/><xsl:value-of select="@title"/></h4>
        </td>
            <xsl:apply-templates select="result"/>
            <xsl:apply-templates select="officer"/>
      </tr>
    </xsl:template>

    <!--選擇框模板-->
    <xsl:template match="result">
                    <xsl:choose>
                        <xsl:when test="@type = "1"">
                            <td width="15%">
                            <xsl:element name="select">
                                <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute>
                                <!--<select name="select">-->
                                    <xsl:choose>
                                        <xsl:when test=".="0"">
                                            <option value="0" selected="selected">請選擇 </option>
                                            <option value="1">符合</option>
                                            <option value="2">基本符合</option>
                                            <option value="3">不符合</option>
                                        </xsl:when>
                                        <xsl:when test=".="1"">
                                            <option value="0">請選擇 </option>
                                            <option value="1" selected="selected">符合</option>
                                            <option value="2">基本符合</option>
                                            <option value="3">不符合</option>
                                        </xsl:when>
                                        <xsl:when test=".="2"">
                                            <option value="0">請選擇 </option>
                                            <option value="1">符合</option>
                                            <option value="2" selected="selected">基本符合</option>
                                            <option value="3">不符合</option>
                                        </xsl:when>
                                        <xsl:when test=".="3"">
                                            <option value="0">請選擇 </option>
                                            <option value="1">符合</option>
                                            <option value="2">基本符合</option>
                                            <option value="3" selected="selected">不符合</option>
                                        </xsl:when>                                        
                                    </xsl:choose>
                                    <!--</select>-->
                                </xsl:element>
                            </td>
                        </xsl:when>
                        <xsl:when test="@type = "2"">
                            <td width="15%">
                                <xsl:element name="select">
                                <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute>
                                    <xsl:choose>
                                        <xsl:when test=".="0"">
                                            <option value="0" selected="selected">請選擇 </option>
                                            <option value="1">是</option>
                                            <option value="2">否</option>
                                        </xsl:when>
                                        <xsl:when test=".="1"">
                                            <option value="0">請選擇 </option>
                                            <option value="1" selected="selected">是</option>
                                            <option value="2">否</option>
                                        </xsl:when>
                                        <xsl:when test=".="3"">
                                            <option value="0">請選擇 </option>
                                            <option value="1">是</option>
                                            <option value="2" selected="selected">否</option>
                                        </xsl:when>                        
                                    </xsl:choose>
                                </xsl:element>
                            </td>
                        </xsl:when>
                        <xsl:when test="@type = "3"">
                            <td width="15%">
                                <xsl:element name="select">
                                <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute>
                                    <xsl:choose>
                                        <xsl:when test=".="0"">
                                            <option value="0" selected="selected">請選擇 </option>
                                            <option value="1">有</option>
                                            <option value="2">無</option>
                                        </xsl:when>
                                        <xsl:when test=".="1"">
                                            <option value="0">請選擇 </option>
                                            <option value="1" selected="selected">有</option>
                                            <option value="2">無</option>
                                        </xsl:when>
                                        <xsl:when test=".="3"">
                                            <option value="0">請選擇 </option>
                                            <option value="1">有</option>
                                            <option value="2" selected="selected">無</option>
                                        </xsl:when>                        
                                    </xsl:choose>
                                </xsl:element>
                            </td>
                        </xsl:when>

                        <xsl:otherwise>
                            <td width="15%">
                            <xsl:element name="textarea">
                                <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute><xsl:value-of select="."/>
                            </xsl:element>
                                <xsl:value-of select="@units"/>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>

    </xsl:template>

        <!--責(zé)任人模板-->
    <xsl:template match="officer">
        <td width="9%" class="tright">責(zé)任人</td>
        <td width="11%">
        <xsl:element name="textarea">
            <xsl:attribute name="name">of_<xsl:value-of select="../@id"/></xsl:attribute>
            <xsl:value-of select="."/>
        </xsl:element>
        </td>
    </xsl:template>

</xsl:stylesheet>
12下一頁閱讀全文
標簽: XML/RSS
相關(guān)文章:
主站蜘蛛池模板: 国产精品久久久久久久久久日本 | 毛片在线高清免费观看 | 国产毛片久久精品 | 国产在线精品成人一区二区三区 | 国产在线视频一区二区三区 | 亚洲国产日产韩国欧美综合 | 欧美精品一二区 | 毛片免费观看的视频 | 91视频欧美| 老司机深夜影院入口aaaa | 看美国毛片 | 中国一级片免费看 | 在线一区视频 | 亚洲精品中文字幕字幕 | 欧美日韩一区二区三区高清不卡 | 精品视自拍视频在线观看 | 一级特一级特色生活片 | 国产成人 免费观看 | 亚洲国产精品a一区二区三区 | 精品视频在线免费看 | 一道本久久| 欧美日韩精品一区二区视频在线观看 | 成人天堂av | 天天干夜夜怕 | 日本亚洲欧美高清专区vr专区 | 一级a级国产不卡毛片 | 欧美精品在线一区二区三区 | 日本在线观看免费看片 | 国产香港特级一级毛片 | 亚洲精品一区二区三区四区 | 国产精品福利视频萌白酱 | 国产一区二区三区国产精品 | 在线欧美| 欧美在线视频免费观看 | 日韩欧美亚洲中字幕在线播放 | 男女男精品视频 | 国产美女91视频 | 美女视频黄a全部免费专区一 | 亚洲精品一区二区久久这里 | 欧美在线一区二区三区不卡 | 手机看片国产日韩 |