1

私は XML と XSL をいじっています。次のような XML ファイルがあります。

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/_xslt/xslt_terms.xsl" type="text/xsl" ?>
    <terms>
       <term><p>Use of Website</p>
           <term>
                <term><p>wording here</p></term>
                <term><p>more words!</p></term>
           </term>
        <term><p>serious words</p></term>
    </terms>

そして次のようなXSLファイル

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" >

<xsl:template match="term">
    <xsl:number level="multiple" format="1. "/>
    <xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

出力は次のように表示されます

 1. Use of Website
    1.1. 
        1.1.1. wording here
        1.1.2. more words

    1.2. serious words

しかし、私が走るとき

<cfoutput>
     <cffile action="read" 
             file="#application.sPath#_xslt/xslt_terms.xsl" 
             variable="variables.xmltrans">
     <cfset variables.xmldoc = XmlParse("#application.sPath#_templates/_ajax/_terms/xml_terms.xml")>
     #XMLTransform(variables.xmldoc, variables.xmltrans)#
</cfoutput>

改行のない巨大なテキスト ブロックが表示されます。したがって、次のようになります。

 1. Use of Website 1.1. 1.1.1. wording here 1.1.2. more words 1.2. serious words

私が言うように、XML と XSL をいじるのはこれが初めてなので、長い間、何かを見逃している可能性があります。

編集

私は、ほとんど仕事をするのに役立ついくつかのコードを見つけました。すべてのタグを削除するように xml を<p>変更し、次のように xsl ファイルを変更しました。

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes"/>

    <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
    </xsl:template>

<xsl:template match="term">
    <p>
        <xsl:number format="1." level="multiple"/>
        <xsl:apply-templates select="@*|node()"/>
    </p>
</xsl:template>

これでほぼ完了ですが、インデントが失われています。上記のようにインデントするためにできることはありますか?

4

1 に答える 1