XSLT使用命名空间转换XML? [英] XSLT Transform XML with Namespaces ?

查看:120
本文介绍了XSLT使用命名空间转换XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于XSLT的问题。

i有一个xml文件:

 <?  xml-stylesheet     type   =  text / xsl    href   =  XSLTFile1.xslt  >  
< otx xmlns = http://iso.org/OTX/1.0.0 xmlns:i18n = http:// i so.org/OTX/1.0.0/i18n\" xmlns:diag = http://iso.org/OTX/1.0.0/DiagCom xmlns:measure = http://iso.org/OTX/1.0.0/Measure\" xmlns:string = http://iso.org/OTX/1.0.0/StringUtil xmlns:fileXml = http://vwag.de/OTX/1.0.0/XmlFile xmlns:日志 = http://iso.org/OTX/1.0.0/Logging xmlns:file = http:// vwag.de/OTX/1.0.0/File\" xmlns:dataPlus = http://iso.org/OTX/1.0.0/DiagDataBrowsingPlus xmlns:event = http://iso.org/OTX/1.0.0/Event\" xmlns:quant = http://iso.org/OTX/1.0.0/Quantities xmlns:hmi = http://iso.org/OTX/1.0.0/HMI xmlns:数学 <跨度class =code-keyword> = http://iso.org/OTX/1.0.0/Math xmlns:flash = http://iso.org/OTX/1.0.0/Flash xmlns:data = http://iso.org/OTX/1.0.0/DiagDataBrowsing xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance xmlns :dt = http://iso.org/OTX/1.0.0/DateTime xmlns:eventPlus = < span class =code-keywo rd> http://iso.org/OTX/1.0.0/EventPlus xmlns:corePlus = http://iso.org/OTX/1.0.0/CorePlus xmlns:xmime = http://www.w3.org/2005/05/xmlmime xmlns:job = http://iso.org/OTX/1.0.0/Job id = < span class =code-keyword> id_e895af47737740b1b0aca75a4f43dd86 name = NewDocument1 = NewOtxProject1Package1 version = 1.0.0.0 timestamp = 2014-04-03T15:11:12.3634145 + 07:00 >
< 程序 >
< span class =code-keyword>< procedure id = id_25f45459817744f083d360ff75c0ea5b 名称 = main visibility = PUBLIC >
< / procedure >
< / procedures >
< / otx >





这是我的XSLT

< pre lang =xml> <? xml version = 1.0 encoding = utf-8 >
< xsl:stylesheet 版本 = 1.0 xmlns:xsl = http:/ /www.w3.org/1999/XSL/Transform\" xmlns = http://iso.org/OTX/1.0.0

xmlns:msxsl = urn:schemas-microsoft-com:xslt exclude-result-prefixes = msxsl

>
< xsl:output 方法 = html 缩进 = / >

<! - < xsl:template match =@ * | node()>
< xsl:copy>
< xsl:apply-templates select =@ * | node()/>
< / xsl:copy>
- >


< xsl:template < span class =code-attribute> match = / >
< html lang = en >
< body >
< 表格 class = form-horizo​​ntal 角色 = 表单 >
< div class = form-group >
< div class = col-sm-10 >
< label > 程序:< / label >
< div = 表格响应 >
< table >
< xsl:for-each 选择 = otx / procedures / procedure >
< tr >
< td < span class =code-keyword>>
< xsl:value-of 选择 = < span class =code-keyword> @ name / >
< / td >
< / tr >
< / xsl:for-each >
< / table >
< / div >
< / div >
< / div >
< / form >
< / body >
< / html >

< / xsl:template >
< / xsl:stylesheet >





当我点击xml文件时,它在浏览器上显示时无法获取数据。

请帮助我,XSLT有什么问题?

解决方案

I have a problem about XSLT.
i have a xml file :

<?xml-stylesheet type="text/xsl" href="XSLTFile1.xslt"?>
<otx xmlns="http://iso.org/OTX/1.0.0" xmlns:i18n="http://iso.org/OTX/1.0.0/i18n" xmlns:diag="http://iso.org/OTX/1.0.0/DiagCom" xmlns:measure="http://iso.org/OTX/1.0.0/Measure" xmlns:string="http://iso.org/OTX/1.0.0/StringUtil" xmlns:fileXml="http://vwag.de/OTX/1.0.0/XmlFile" xmlns:log="http://iso.org/OTX/1.0.0/Logging" xmlns:file="http://vwag.de/OTX/1.0.0/File" xmlns:dataPlus="http://iso.org/OTX/1.0.0/DiagDataBrowsingPlus" xmlns:event="http://iso.org/OTX/1.0.0/Event" xmlns:quant="http://iso.org/OTX/1.0.0/Quantities" xmlns:hmi="http://iso.org/OTX/1.0.0/HMI" xmlns:math="http://iso.org/OTX/1.0.0/Math" xmlns:flash="http://iso.org/OTX/1.0.0/Flash" xmlns:data="http://iso.org/OTX/1.0.0/DiagDataBrowsing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="http://iso.org/OTX/1.0.0/DateTime" xmlns:eventPlus="http://iso.org/OTX/1.0.0/EventPlus" xmlns:corePlus="http://iso.org/OTX/1.0.0/CorePlus" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:job="http://iso.org/OTX/1.0.0/Job" id="id_e895af47737740b1b0aca75a4f43dd86" name="NewDocument1" package="NewOtxProject1Package1" version="1.0.0.0" timestamp="2014-04-03T15:11:12.3634145+07:00">
  <procedures>
    <procedure id="id_25f45459817744f083d360ff75c0ea5b" name="main" visibility="PUBLIC">
    </procedure>
  </procedures>
</otx>



and this is my XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://iso.org/OTX/1.0.0"

    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"

>
  <xsl:output method="html" indent="yes"/>

  <!--<xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>-->

  <xsl:template match="/">
    <html lang="en">
      <body>
        <form class="form-horizontal" role="form">
          <div class="form-group">
            <div class="col-sm-10">
              <label>Procedures:</label>
              <div class="table-responsive">
                <table>
                  <xsl:for-each select="otx/procedures/procedure">
                    <tr>
                      <td>
                        <xsl:value-of select="@name"/>
                      </td>
                    </tr>
                  </xsl:for-each>
                </table>
              </div>
            </div>
          </div>
        </form>
      </body>
    </html>

  </xsl:template>
</xsl:stylesheet>



When i clicked on xml file, it cannot get data when showing on browser.
please help me, what is wrong in the XSLT?

解决方案

这篇关于XSLT使用命名空间转换XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆