[xml] how can I divided an xml file in plus files by way of an element section?



Hi to All,
I'm Davide, I have the follow question:
Is possible to divide an xml file in plus files by way of an element
section?

Example:

File1.xml
<Ele1>
        <Sec1>Section1</Sec1>
        <Sec2>Section2</Sec3>
        <Sec3>Section3</Sec3>
</Ele1>

Trasform ->

Section1.htm
<Ele1>
        <Sec1>Section1</Sec1>
</Ele1>

Section2.htm
<Ele1>
        <Sec2>Section2</Sec2>
</Ele1>

Section3.htm
<Ele1>
        <Sec3>Section3</Sec3>
</Ele1>

I know that with xalan is possible, enough this code in a xsl file:

        <xsl:template match="/">
                <!--Index-->
                <xsl:variable name="filename" select="concat($data/RECORD/@ID,'.htm')"/>
                <xalan:write select="$filename">
                        <xsl:apply-templates select="$htmlpage/*"/>
                </xalan:write>
                <xsl:if test="$data/RECORD/RECORD-META/@RECORDTYPE!='NEWS'">
                        <xsl:for-each select="$data/RECORD/BODY/SECTION">
                                <xsl:variable name="filename"
select="concat($data/RECORD/@ID,'_',position(),'.htm')"/>
                                <xalan:write select="$filename">
                                        <xsl:call-template name="transform-onefile">
                                                <xsl:with-param name="data1" select="."/>
                                        </xsl:call-template>
                                </xalan:write>
                        </xsl:for-each>
                </xsl:if>
        </xsl:template>
        <xsl:template name="transform-onefile">
                <xsl:param name="data1"/>
                ******
                ******
                ******
        </xsl:template>


Thanks to everyone

Davide




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]