[英]WSO2/Synapse: using properties with the XSLT mediator
Does anyone have an example of how to reference a property on the xslt mediator within the xslt itself? 有没有人有一个如何在xslt本身的xslt介体上引用属性的例子?
The documentation says 文件说
property - Allows optional parameters to be passed into the transformations. property - 允许将可选参数传递给转换。 These properties are corresponding to the XSL parameters and can be accessed during transformation. 这些属性对应于XSL参数,可以在转换期间访问。
I cannot find an example of how to refer to this from within the xslt itself. 我找不到如何从xslt本身引用它的示例。 I've added the namespace http://ws.apache.org/ns/synapse to the xslt document but it cannot resolve the get-property() function. 我已将命名空间http://ws.apache.org/ns/synapse添加到xslt文档中,但它无法解析get-property()函数。
Say you have 2 properties in your synapse config. 假设您的synapse配置中有2个属性。 Then you want to pass them to XSLT and refer it from there. 然后你想将它们传递给XSLT并从那里引用它。 So inside the synapse config, 所以在synapse配置中,
<property name="email" expression="//request/email"/>
<property name="name" expression="//request/name"/>
<xslt key="orderTransformer">
<property name="email" expression="get-property('email')"/>
<property name="name" expression="get-property('name')"/>
</xslt>
Now insdie the XSLT here is how you refer them. 现在,这里的XSLT是你如何引用它们的。 First Define them as two params. 首先将它们定义为两个参数。
<xsl:param name="email"/>
<xsl:param name="name"/>
Use them as $email, $name in where u need. 使用它们作为$ email,$ name在你需要的地方。
Example XSLT 示例XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://wso2.org/sample/shop/order">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="email"/>
<xsl:param name="name"/>
<xsl:template match="/">
<xsl:apply-templates select="//ns1:AddOrder"/>
</xsl:template>
<xsl:template match="ns1:AddOrder">
<ns1:AddOrder>
<ns1:email>
<xsl:value-of select="$email"/>
</ns1:email>
<ns1:name>
<xsl:value-of select="$name"/>
</ns1:name>
</ns1:AddOrder>
</xsl:template>
</xsl:stylesheet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.