xsl-list
[Top] [All Lists]

[xsl] Assigning multiple xml's file names into variable name using for-each possible?

2006-07-18 02:24:43
I have a scenario where I have loads of xml which are all similar in
structure, but variy in content. I want to render all this xml's
using the same xsl file to get a html output for each xml file using
saxon parser.

So, what I was trying to do is to make a seperate xml file listing
all the xml file to be processed. e.g: xmlFileList.xml 

        <ContentGroup name="Arts">
                <ContentFile>S207.xml</ContentFile>
                <ContentFile>S103_2.xml</ContentFile>
                <ContentFile>DD03.xml</ContentFile>
                .... etc etc
        </ContentGroup>

the individual xml's e.g: S207.xml will look like 

<Item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
        <Unit>
                <UnitID>Chapter 1</UnitID>
                <UnitTitle>Motion along a line</UnitTitle>
                <Session id="SES001">
                        <Section id="SEC001">
                                .....


And in the xsl file, trying to loop thro to get each file name and
process it like:

<xsl:template match="/"> <!-- of xmlFileList.xml -->
        <xsl:for-each select="//ContentFile">
                <xsl:variable name="fileName" select="node()"/>
                <xsl:variable name="currentFile" 
select="document('{$fileName}')"/>

                <!--?? VALID?? TRYING TO ACHIEVE  select="document('s207.XML') 
AND
SO ON -->
                <xsl:variable name="CourseId" 
select="substring-before($fileName,
'.xml')"/>

                <xsl:for-each select="$currentFile//Unit/Session/Section"> <!--
THIS SHOWS ERR -->
                <xsl:variable name="filename"
select="concat($CourseId,'_',@id,'.html')"/>
                <xsl:result-document href="{$filename}" format="html">
                        <xsl:call-template name="Main">
                           ...
                        </xsl:call-template>
                </xsl:result-document>
        </xsl:for-each>


I read somewhere I cannot load more than 1 xml doc using
document(''). Is that the reason for my err? Would be great if
someone explains me the mistake and how i con fix it. If no fix, then
alternate method to get the result which i want.

Thanks
karl



                
___________________________________________________________ 
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" ? The 
Wall Street Journal 
http://uk.docs.yahoo.com/nowyoucan.html

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>