我有这个XSLT映射:
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:wor1="http://www.example.com/services/">
<xsl:template match="/">
<wor1:ReceiveWorkOrderNotification>
<xsl:apply-templates select="UpdateTaskAssignmentEx/Task" />
<xsl:apply-templates select="UpdateTaskAssignmentEx/Assignment" />
</wor1:ReceiveWorkOrderNotification>
</xsl:template>
<xsl:template match="Task">
<Task>
<wor1:taskId><xsl:value-of select="CallID"/></wor1:taskId>
</Task>
</xsl:template>
<xsl:template match="Assignment">
<Assignment>
<wor1:engineer><xsl:value-of select="AssignedEngineers"/></wor1:engineer>
</Assignment>
</xsl:template>
</xsl:stylesheet>
结果是:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<wor1:ReceiveWorkOrderNotification xmlns:wor1="http://www.example.com/services>
<header>
<wor1:taskId>test6666</wor1:taskId>
</header>
<Task>
<wor1:taskId>test6666</wor1:taskId>
</Task>
<Assignment>
<wor1:engineer>John Smith</wor1:engineer>
</Assignment>
</wor1:ReceiveWorkOrderNotification>
</s:Body>
</s:Envelope>
但我希望分配中的现场工程师能够参与任务。有人可以解决这个,因为我尝试不同的情况,但总是收到错误。 我想要这个:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<wor1:ReceiveWorkOrderNotification xmlns:wor1="http://www.example.com/services>
<header>
<wor1:taskId>test6666</wor1:taskId>
</header>
<Task>
<wor1:taskId>test6666</wor1:taskId>
<wor1:engineer>John Smith</wor1:engineer>
</Task>
</wor1:ReceiveWorkOrderNotification>
</s:Body>
</s:Envelope>
答案 0 :(得分:1)
重新组织您的XSLT:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:wor1="http://www.example.com/services/">
<xsl:template match="/">
<wor1:ReceiveWorkOrderNotification>
<Task>
<xsl:apply-templates select="UpdateTaskAssignmentEx/Task" />
<xsl:apply-templates select="UpdateTaskAssignmentEx/Assignment" />
</Task>
</wor1:ReceiveWorkOrderNotification>
</xsl:template>
<xsl:template match="Task">
<wor1:taskId><xsl:value-of select="CallID"/></wor1:taskId>
</xsl:template>
<xsl:template match="Assignment">
<wor1:engineer><xsl:value-of select="AssignedEngineers"/></wor1:engineer>
</xsl:template>
</xsl:stylesheet>