Xslt 在这个xsl中,如何为每一个都创建一个?

Xslt 在这个xsl中,如何为每一个都创建一个?,xslt,jdeveloper,bpel,Xslt,Jdeveloper,Bpel,我从Bpel流程中的服务获得此结果。 如何使用OSTypeOutput及其内部为每个对象创建一个 测试“serv”的值 我正在尝试做一个转变 <siOutPut> -<OOPreOutput xmlns="http://my.web.com/test/types"> -<OSTypes xmlns:ns1="http://my.web.com/test/servtp"> -<ns1:OSTypeOutput>

我从Bpel流程中的服务获得此结果。 如何使用OSTypeOutput及其内部为每个对象创建一个 测试“serv”的值

我正在尝试做一个转变

<siOutPut>
  -<OOPreOutput xmlns="http://my.web.com/test/types">
    -<OSTypes xmlns:ns1="http://my.web.com/test/servtp">
        -<ns1:OSTypeOutput>
            <ns1:serv>A1</ns1:serv>
            <ns1:serv>A2</ns1:serv>
            <ns1:serv>A3</ns1:serv>
        </ns1:OSTypeOutput>
    </OSTypes>
  </OOPreOutput>
</siOutPut>

-
-
-
A1
A2
A3
我试过这种方法,但什么也得不到:

  <xsl:param name="Param">
    <xsl:text disable-output-escaping="no">A3</xsl:text>
  </xsl:param>
  <xsl:template match="/">
    <ns1:GetTestResponse>
     <ns1:MyId>
       <xsl:for-each select="/ns1:OOPreOutput/ns1:OSTypes/ns1:OSTypeOutput">
         <xsl:if test="(./serv = $Param)">
           <xsl:value-of select="'Found'"/>
         </xsl:if>  
       </xsl:for-each>
     </ns1:MyId>      
    </ns1:GetTestResponse>
  </xsl:template>

A3
我做了这个测试:

<ns1:MyId>
  <xsl:for-each select="/ns1:OOPreOutput/ns1:OSTypes">
       <xsl:value-of select="current()"/>
   </xsl:for-each>
</ns1:MyId>  

得到这个结果: A1A2A3

我也做了这个测试,但没有结果:

  <xsl:param name="Param">
    <xsl:text disable-output-escaping="no">A3</xsl:text>
  </xsl:param>
  <xsl:template match="/">
    <ns1:GetTestResponse>
     <ns1:MyId>
       <xsl:if test="/ns1:OOPreOutput/ns1:OSTypes/ns1:OSTypeOutput/ns1:serv = $Param">
           <xsl:value-of select="'Found'"/>
       </xsl:if>  
     </ns1:MyId>      
    </ns1:GetTestResponse>
  </xsl:template>

A3
我稍微改变了一下输出:

-<siOutPut>
  -<OOPreOutput xmlns="http://int.clear.com/types">
    +<Deliv></Deliv>
    <OSTypes>
    <ns1:serv xmlns:ns1="http://my.test.com/web/services">A1</ns1:serv>
    <ns1:serv xmlns:ns1="http://my.test.com/web/services">A2</ns1:serv>
    <ns1:serv xmlns:ns1="http://my.test.com/web/services">A3</ns1:serv>
    </OSTypes>
  </OOPreOutput>
</siOutPut>
-
-
+
A1
A2
A3

我应该如何验证ns1:serv是否具有“A3”值?

您没有在样式表中声明任何名称空间。重新编写样式表:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://my.web.com/test/servtp" xmlns:ns2="http://my.web.com/test/types" version="1.0">

<xsl:param name="Param">
    <xsl:text disable-output-escaping="no">A3</xsl:text>
</xsl:param>
<xsl:template match="/">
    <ns1:GetTestResponse>
        <ns1:MyId>
            <xsl:for-each select="/siOutPut/ns2:OOPreOutput/ns2:OSTypes/ns1:OSTypeOutput">
                <xsl:if test="(./ns1:serv = $Param)">
                    <xsl:value-of select="'Found'"/>
                </xsl:if>  
            </xsl:for-each>
        </ns1:MyId>      
    </ns1:GetTestResponse>
</xsl:template>

</xsl:stylesheet>

A3
但是,没有必要对每一个都做一个检查,因为您只想检查“serv”是否存在,并带有一些值。 也可以这样做:

<xsl:template match="/">
<ns1:GetTestResponse>
    <ns1:MyId>
            <xsl:if test="siOutPut/ns2:OOPreOutput/ns2:OSTypes/ns1:OSTypeOutput/ns1:serv = $Param">
                <xsl:value-of select="'Found'"/>
            </xsl:if>  
    </ns1:MyId>      
</ns1:GetTestResponse>
</xsl:template>

我会尝试使用应用模板来简化逻辑。我认为问题可能是。我得说它是“找到的”。我认为你没有匹配。我不认为可以解决这个问题

<xsl:param name="Param">
 <xsl:text disable-output-escaping="no">A3</xsl:text>
</xsl:param>
<xsl:template match="/">
 <ns1:GetTestResponse>
  <ns1:MyId>
   <xsl:apply-templates />
  </ns1:MyId>      
 </ns1:GetTestResponse>
</xsl:template>

<xsl:template match="ns1:OSTypeOutput">
   <xsl:for-each select="ns1:serv">
     <xsl:if test=".= $Param">
       <xsl:text>'Found'</xsl:text>
     </xsl:if>  
   </xsl:for-each>
</xsl:template>

A3
“发现”

在更改输出后,我为每个人都做了这样的操作,并且工作正常:

<xsl:for-each select="/ns2:OOPreOutput/ns2:OSTypes">
    <xsl:if test="(./ns1:serv = $Param)">
         <xsl:value-of select="'Found'"/>
    </xsl:if>  
</xsl:for-each>

并按照Lingamurthy的建议进行直接测试

<xsl:if test="ns2:OOPreOutput/ns2:OSTypes/ns1:serv = $Param">
    <xsl:value-of select="'Found'"/>
<xsl:if>


谢谢大家。

请识别编程语言此转换是在带有JDev的Oracle BPel流程中完成的。我不使用任何其他语言来执行此操作。
select=“/ns1:OOPreOutput/ns1:OSTypes”
将不起作用,因为
ns1:OOPreOutput
不是该XML的根节点(它上面有一个
siOutput
),我是否像这样指定根节点:/ns1:siOutput/ns1:OOPreOutput/ns1:OSTypes/ns1:OSTypeOutputI声明了名称空间。我尝试了第二个建议,但没有得到“发现”。