Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 在XSLT转换中保留属性之间的空白_Xml_Xslt - Fatal编程技术网

Xml 在XSLT转换中保留属性之间的空白

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:

<?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