liujia

          導(dǎo)航

          <2006年7月>
          2526272829301
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          隨筆分類

          隨筆檔案

          統(tǒng)計(jì)

          留言簿(1)

          閱讀排行榜

          評(píng)論排行榜

          2006年7月4日 #

          XSLT1中處理含有默認(rèn)名稱空間聲明的XML文檔時(shí)的XPATH問(wèn)題

          XSLT1中使用XPATH對(duì)含有默認(rèn)名稱空間聲明的XML文檔進(jìn)行查找時(shí)是查不出內(nèi)容的

          例如對(duì)于
          <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>
          應(yīng)用
          <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>
          是沒(méi)有效果的.
          需要給默認(rèn)的名稱空間指定一個(gè)前綴
          <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>
          據(jù)說(shuō)XSLT2和XPATH2會(huì)解決這個(gè)問(wèn)題

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


          posted @ 2006-07-04 23:43 劉佳 閱讀(375) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 洮南市| 台南县| 海城市| 南溪县| 惠东县| 苏尼特左旗| 临安市| 利川市| 湟中县| 同德县| 兴隆县| 邢台市| 桐庐县| 勃利县| 吴江市| 军事| 长白| 梁河县| 江北区| 资溪县| 乌兰察布市| 株洲县| 绍兴市| 甘孜| 南丹县| 常山县| 香格里拉县| 江西省| 安西县| 合江县| 邢台市| 璧山县| 化隆| 忻州市| 贵州省| 陕西省| 宁武县| 太仆寺旗| 界首市| 南昌市| 宁海县|