我需要能夠使用XSLT創建下列格式的XML元素的結束標記創建XML元素:不使用XSLT
<element foo="x" bar="y" />
我似乎僅限於:
<element foo="x" bar="y"></element>
原因我們是否有流程更改,但客戶端界面無法更改。你可能會建議這些基本上是平等的,你會是對的,但我們不能,但是,假設我們的客戶正在使用合理的XML解析技術。
我曾嘗試:
<Mapping>
<xsl:attribute name="Source">
<xsl:value-of select="@Source"/>
</xsl:attribute>
<xsl:attribute name="Destination">
<xsl:value-of select="@Destination"/>
</xsl:attribute>
</Mapping>
這顯然增加了不必要的結束標記,並且:
<xsl:element name="Mapping">
<xsl:attribute name="Source">
<xsl:value-of select="@Source"/>
</xsl:attribute>
<xsl:attribute name="Destination">
<xsl:value-of select="@Destination"/>
</xsl:attribute>
</xsl:element>
這還增加了不必要的結束標記。
任何人都可以幫忙嗎?
這兩者在語義上是相同的。如果你的客戶認爲這是一個變化,那麼肯定這是他們的問題不是你的問題? – Joe
你可以向我們展示.NET代碼進行轉換嗎?沒有XSLT方式來執行某種格式的序列化空元素的格式,例如。 ' '或' '而不是' '所以我很驚訝你說你得到一個帶有結束標籤的長表單。 –
谷歌搜索給了http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/3f5a3a5f-d088-4664-9216-e4ff8e577a0f。你試過了嗎? – Gordon