如何将变量get从javascript传递到xsl

时间:2012-05-13 04:59:30

标签: xslt

我有一个像下面这样的xml文件,我想过滤掉目标记录,引用它的URL说 http://localhost/rc.xml?rid = 2 ,然后是网络浏览器将显示rcid = 2

的所有记录
    <?xml version="1.0">

    <?xml-stylesheet type="text/xsl" href="rc.xsl" ?>

    <RInfo "Location="KLN">
    <Info rcid="1" >1

    <RCHNo>1</RCHNo>

        <BrandNo>J252</BrandNo>

<Age>6</Age>

    </Info>
    <Info rcid="1" >1

<RCHNo>2</RCHNo>

<BrandNo>J132</BrandNo>

<Age>6</Age>

    </Info>
    <Info rcid="2" >2
<RCHNo>1</RCHNo>

<BrandNo>K152</BrandNo>

<Age>3</Age>

    </Info>
    <Info rcid="2" >2
<RCHNo>2</RCHNo>

<BrandNo>K152</BrandNo>

<Age>4</Age>

    </Info>
    </RInfo>

我下面有一个xsl报废,我想要做的是通过javascript获取url参数并按下它以检索“=”之后的值

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

    xmlns:xalan="http://xml.apache.org/xslt"

    xmlns:my-ext="ext1" 

    extension-element-prefixes="my-ext" 

    version="1.0">

 <xsl:output method="xml"/>
      <xalan:component prefix="my-ext" elements="getrid">
<xalan:script lang="javascript">
<![CDATA[
    function getrid() {
      var ridstr= window.location.toString().split("=");
      //alert ("2");
      return ridstr[1];
      }
]]>
     </xalan:script>
 </xalan:component>
 ::::
 ::::
 <xsl:if test="@rcid=my-ext:getrid">

0 个答案:

没有答案
相关问题