Xml 在XSLT转换中保留属性之间的空白
我有以下XML:Xml 在XSLT转换中保留属性之间的空白,xml,xslt,Xml,Xslt,我有以下XML: <?xml version="1.0"?> <products> <product at1="a" at2="b" at3="c"> </product> </products> 不,不适用于标准XML/XSLT工具 这些信息不是XML信息集的一部分,当XML解析器读取XML时,这些信息将丢失。因此,无法在输出中保留 您需要用其他东西修改输出以应用这
<?xml version="1.0"?>
<products>
<product at1="a"
at2="b"
at3="c">
</product>
</products>
不,不适用于标准XML/XSLT工具 这些信息不是XML信息集的一部分,当XML解析器读取XML时,这些信息将丢失。因此,无法在输出中保留
您需要用其他东西修改输出以应用这种格式。非常类似:在我开始编写自己的xml解析器之前,您能推荐一些工具或库来读取xml,同时保留所有空白吗?@AlexSpurling我也有一个与您类似的问题。但是,为什么不在第一次使用XSLT之后,只执行一个脚本(例如python)来格式化缩进呢?这可能比重写整个XML解析器快得多:)希望能有所帮助!
<?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>
<?xml version="1.0"?>
<products>
<product at1="a" at2="b" at3="c">
</product>
</products>
xsltproc -o test2.xml test.xslt test.xml