liujia

          統計

          留言簿(1)

          閱讀排行榜

          評論排行榜

          XSLT1中處理含有默認名稱空間聲明的XML文檔時的XPATH問題

          XSLT1中使用XPATH對含有默認名稱空間聲明的XML文檔進行查找時是查不出內容的

          例如對于
          <requestHierarchySelectResult xmlns=http://www.lightcc.com/ns xmlns:cs="http://www.customsolids.com">
          ???
          <request>
          ???????
          <created_dt>05/05/2000 00:00:00</created_dt>
          ???????
          <created_tm>01/01/1900 14:02:46</created_tm>
          ???????
          <cs:request_id>100002</cs:request_id>
          ???
          </request>
          </requestHierarchySelectResult>
          應用
          <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"?
          ???xmlns
          ="http://www.lightcc.com/ns"
          ???xmlns
          :cs="http://www.customsolids.com"
          >
          ???<xsl:template match="/">
          ??????<root><xsl:apply-templates? select
          ="/*/request"/></root>
          ???</xsl:template>
          ???<xsl:template? match="*|@*|node()"/>
          ???<xsl:template? match="request">
          ??????
          <gotHere><xsl:value-of? select="."/></gotHere>
          ???</xsl:template>
          </xsl:stylesheet>
          是沒有效果的.
          需要給默認的名稱空間指定一個前綴
          <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"?
          ???xmlns:lc
          ="http://www.lightcc.com/ns"
          ???xmlns
          :cs="http://www.customsolids.com"
          >
          ???<xsl:template match="/">
          ???????
          <root><xsl:apply-templates? select="/*/lc:request"/></root>
          ???</xsl:template>
          ???<xsl:template? match="*|@*|node()"/>
          ???<xsl:template? match="lc:request">
          ??????
          <gotHere><xsl:value-of? select="."/></gotHere>
          ???</xsl:template>
          </xsl:stylesheet>
          據說XSLT2和XPATH2會解決這個問題

          參考:
          ???http://www.edankert.com/defaultnamespaces.html
          ???http://www.topxml.com/people/bosley/defaultns.asp


          posted on 2006-07-04 23:43 劉佳 閱讀(372) 評論(0)  編輯  收藏 所屬分類: XML

          主站蜘蛛池模板: 神木县| 温州市| 张家港市| 望谟县| 白朗县| 东源县| 皋兰县| 丰城市| 宜兰市| 苍南县| 清涧县| 闻喜县| 东丰县| 灵寿县| 乌拉特中旗| 新巴尔虎右旗| 甘德县| 澜沧| 改则县| 忻城县| 武汉市| 玉山县| 望奎县| 略阳县| 金阳县| 浙江省| 静海县| 荥经县| 平阳县| 石棉县| 鄄城县| 江西省| 彭阳县| 武义县| 商南县| 新营市| 乐清市| 凤台县| 大冶市| 平原县| 喜德县|