[英]xml transformation using xslt 2.0
I'm trying to do SOAP to XML transformation in XSLT 2.0, this is the source xml: 我正在尝试在XSLT 2.0中进行SOAP到XML的转换,这是源xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xi="http://www.xcdm.com">
<soapenv:Header/>
<soapenv:Body>
<xi:root>
<xmlHeader>
<timestamp>1232135468</timestamp>
<source>xds unit</source>
</xmlHeader>
<xmlBody>
<method>create</method>
<customer>
<custA>VOC-Prov</custA>
<custB>vocprov</custB>
</customer>
<Item>
<subElmt1>12345</subElmt1>
<subElmt2>534321</subElmt2>
</Item>
</xmlBody>
</xi:root>
</soapenv:Body>
` `
I have been looking for days for a way to transform the structure using XSLT 2.0 so that the output will structured by this one : 我一直在寻找一种使用XSLT 2.0转换结构的方法,以使输出由此结构化:
<customer version="1.0">
<custA>VOC-Prov</custA>
<custB>vocprov</custB>
<Item name="constName" method="value from the method element (create)">
<Attribute name="subElmt1">value of subElmt1 element</Attribute>
<Attribute name="subElmt2">534321</Attribute>
</Item>
</customer>
Any help on this would be greatly appreciated! 任何帮助,将不胜感激!
I have been looking for days for a way to transform the structure 我一直在寻找改变结构的方法的日子
Not sure why you're having such trouble with this, as it seems like a relatively easy task: 不确定为什么会遇到这种麻烦,因为这似乎是一个相对容易的任务:
XSLT 2.0 XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<customer version="1.0">
<xsl:variable name="body" select="//xmlBody" />
<xsl:copy-of select="$body/customer/*" copy-namespaces="no"/>
<Item name="constName" method="{$body/method}">
<xsl:for-each select="$body/Item/*">
<Attribute name="{name()}">
<xsl:value-of select="." />
</Attribute>
</xsl:for-each>
</Item>
</customer>
</xsl:template>
</xsl:stylesheet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.