我正在嘗試格式化xml並將一些字段複製到較低級別,因此我在將密鑰導入到Access時有密鑰。 試圖將字段號添加到ActivityLog的部分。 就像我爲標識符做的那樣,但我沒有找到一種方法來處理數字 我無法調整xml,因爲這是應用程序的導出。使用XSLT轉換xml以在較低級別添加密鑰
<?xml version="1.0" encoding="windows-1252"?>
<NotificationReport xmlns="http://www.xyyyxx.com/extraction/notification">
<NotificationElement>
<Identifier>13689</Identifier>
<NotificationElementAcceptance>
<NotificationElement>
<VersionNumber>
<Number>2</Number>
</VersionNumber>
<NotificationElementAcceptance>
<ActivityLogs>
<ActivityLog>
<ActivityLogId>NE-720177</ActivityLogId>
<ActivityStartDateTime>2015-11-03T17:09:30.475</ActivityStartDateTime>
<CreationDateTime>2015-11-03T17:09:30.475</CreationDateTime>
<ActivityIndex>1</ActivityIndex>
<CompleteProcessStatus>Change notification element</CompleteProcessStatus>
</ActivityLog>
</ActivityLogs>
</NotificationElementAcceptance>
</NotificationElement>
</NotificationElementAcceptance>
</NotificationElement>
</NotificationReport>
- >我已創建了現在,直到XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ActivityLog">
<ActivityLog>
<Identifier><xsl:value-of select="../../../../../Identifier"/></Identifier>
<xsl:apply-templates select="@*|node()"/>
</ActivityLog>
</xsl:template>
預期結果
<?xml version="1.0" encoding="utf-8"?>
<NotificationReport xmlns="http://www.xyyyxx.com/extraction/notification">
<NotificationElement>
<Identifier>13689</Identifier>
<NotificationElementAcceptance>
<NotificationElement>
<VersionNumber>
<Number>2</Number>
</VersionNumber>
<NotificationElementAcceptance>
<ActivityLogs>
<ActivityLog>
<Identifier>13689</Identifier>
<VersionNumber>2</VersionNumber>
<ActivityLogId>NE-720177</ActivityLogId>
<ActivityStartDateTime>2015-11-03T17:09:30.475</ActivityStartDateTime>
<CreationDateTime>2015-11-03T17:09:30.475</CreationDateTime>
<ActivityIndex>1</ActivityIndex>
<CompleteProcessStatus>Change notification element</CompleteProcessStatus>
</ActivityLog>
</ActivityLogs>
</NotificationElementAcceptance>
</NotificationElement>
</NotificationElementAcceptance>
</NotificationElement>
</NotificationReport>
您能否提供您的示例所需的輸出?這會有很大的幫助。 – hielsnoppe
預期的結果被添加到問題中(沒有得到makup正確) –