[英]COPYING INPUT XML TO OUTPUT by XSLT
下面是我的輸入xml
<ServiceIncident xmlns="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2">
<RequesterID/>
<ProviderID>INC0011731</ProviderID>
<ProviderPriority>4</ProviderPriority>
<WorkflowStatus>NEW</WorkflowStatus>
<Transaction>
<Acknowledge>1</Acknowledge>
<StatusCode>0</StatusCode>
<Comment>String</Comment>
<TransactionName>Problem_Submittal</TransactionName>
<TransactionType>2</TransactionType>
<TransactionDateTime>2012-10-19T16:05:56Z</TransactionDateTime>
<TransactionNumber>2012-10-19T16:05:56Z:1ae9b6a79901fc40fa75c64e1cdcc3b4</TransactionNumber>
<TransactionRouting>MX::ITELLASNINCBRDG</TransactionRouting>
<DataSource>ServiceNow</DataSource>
<DataTarget>NASPGR72</DataTarget>
</Transaction>
</ServiceIncident>
我的要求是我需要將整個輸入復制為輸出,但輸入中的一個字段需要在輸出中進行更改。
以下是我在xslt中用於復制輸入的代碼。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:r2="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
通過在xslt中使用上述代碼,我能夠將整個輸入復制為輸出,但是在我的要求中,我需要TransactionDateTime應該映射而不是硬編碼值
<TransactionDateTime>2012-10-19T16:05:56Z</TransactionDateTime>
我需要在事務中使用此功能而不是硬代碼。 下面是我的xslt代碼,但沒有給出輸出
<xsl:template match="r2:TransactionDateTime">
<xsl:value-of select="current-dateTime()"/>
</xsl:template>
添加與要更改的節點匹配的另一個模板,然后在其中執行更改:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:r2="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="r2:DataSource">
<xsl:copy>Maximo</xsl:copy>
</xsl:template>
</xsl:stylesheet>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.