0
我有這樣的XML:如何反轉義的元素,並刪除namespace屬性
<DiaryEvent name="CreateAppointment">
<appointmentId>e69cbf2e-3de7-e411-9fbf-b161700bfb88</appointmentId>
<originalStartDateTime>2015/04/20 11:15</originalStartDateTime>
<originalEndDateTime>2015/04/20 11:30</originalEndDateTime>
<originalAssignee>DOMAIN\user</originalAssignee>
<initialData><Task id="b1520763-1369-482e-9133-1e40e5b476d0" userName="DOMAIN\user" createdAt="2015/04/20 10:10:25" formTypeId="00000000-0000-0000-0000-000000000000" formTypeName="Client Visit" isScheduled="true" minimumFormVersion="0" xmlns="http://mycompany.com/Schemas/TaskXmlSchema/1.0/">
<DataItems>
<DataItem name="QLCl_Client No" type="int">123</DataItem>
</DataItems>
</Task></initialData>
</DiaryEvent>
我需要從<initialData>
元素提取XML,UNESCAPE,然後取出namespace屬性。
我已經使用這個成功實現了第一部分:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:copy>
<xsl:value-of select="//initialData" disable-output-escaping="yes"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
但是,我無法刪除namespace屬性,xmlns="http://mycompany.com/Schemas/TaskXmlSchema/1.0/"
,從輸出:
<Task id="b1520763-1369-482e-9133-1e40e5b476d0" userName="DOMIAN\user"
createdAt="2015/04/20 10:10:25"
formTypeId="00000000-0000-0000-0000-000000000000"
formTypeName="Client Visit"
isScheduled="true"
minimumFormVersion="0"
xmlns="http://mycompany.com/Schemas/TaskXmlSchema/1.0/">
<DataItems>
<DataItem name="QLCl_Client No" type="int">123</DataItem>
</DataItems>
</Task>
我曾嘗試各種組合其中:
<xsl:template match="@xmlns" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
and
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:t="http://mycompany.com/Schemas/TaskXmlSchema/1.0/"
exclude-result-prefixes="t" >
沒有成功。我如何刪除名稱空間屬性?
謝謝。是否有可能將兩者結合起來?對不起,我對XSLT比較陌生。 – Simon
@Simon您使用的是什麼版本的XSLT和處理器? –
使用.Net 3.5的XSLT 1.0 – Simon