私は、次のXMLがありますは、XSLT変換に属性間の空白を保持
<?xml version="1.0"?>
<products>
<product at1="a"
at2="b"
at3="c">
</product>
</products>
と、次のXSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
は理論的には、XSLTは、入力XMLは変更しないままにしておきますが。しかし、私が処理した後に取得する出力は次のようになります。
<?xml version="1.0"?>
<products>
<product at1="a" at2="b" at3="c">
</product>
</products>
は、私は、属性間の間隔を再フォーマットからトランスを防ぐことができ、私の方法はあります。私は、入力と出力の両方のXMLが機能的に同等であることを理解していますが、人間が読みやすいように、行ごとの属性を保持したいと考えています。それが重要な場合は、私は、この変換を行うにはUbuntuのxsltprocのを使用しています:
xsltproc -o test2.xml test.xslt test.xml
非常によく似ています:http://stackoverflow.com/questions/4617993/how-to-preserve-whitespace-within-an-elements-opening-tag-in-xslt – mzjn
http://stackoverflow.com/questions/ 1265255/xml-serialization中のnew-line-on-a-line-line属性 –