Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2010, 09:31 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Creating a temporary document

Hi,

Is the below code correct? I am trying to create a temporary document by pulling about 400 xml files into a variable.

The below code doesnt return anything. I am using Saxon with -t enabled. Saxon reports that the files are being processed.


Code:
<xsl:variable name="filter">
        <xsl:value-of select="concat($working-folder, '?select=*.xml;recurse=no;on-error=ignore')"/>
</xsl:variable>
<xsl:variable name="dm.manifest">
        <manifest>
            <xsl:for-each select="collection($filter)">
                <xsl:for-each select="//dmc">
                    <xsl:copy>
                        <xsl:copy-of select="@*"/>
                        <xsl:apply-templates/>
                    </xsl:copy>
                </xsl:for-each>
            </xsl:for-each>
        </manifest>
    </xsl:variable>
sample file pulled in by collection:

Code:
<dmodule id="someid">
    <idstatus>
        <dmaddres>
            <dmc>
                <avee>
                    <modelic>Model Number</modelic>
                    <sdc>0</sdc>
                    <chapnum>0</chapnum>
                    <section>0</section>
                    <subsect>0</subsect>
                    <subject>00</subject>
                    <discode>00</discode>
                    <discodev>00</discodev>
                    <incode>000</incode>
                    <incodev>0</incodev>
                    <itemloc>0</itemloc>
                </avee>
            </dmc>
        </dmaddres>
    </idstatus>
</dmodule>
The xsl call:

Code:
<xsl:value-of select="$dm.manifest/manifest"/>
Thanks,
 
Old February 26th, 2010, 09:42 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

The xsl:value-of looks odd at least with the nodes you are trying to process. On the other hand your elements seem to have some text contents so that content should show up, all concatenated together though.
I am not sure where the problem is, I would start with doing
Code:
<xsl:copy-of select="$dm.manifest"/>
to see whether that variable contains what you expect.

Note that the <xsl:variable><xsl:value-of select="..."/></xsl:variable> can and should be shortened to <xsl:variable name="dm.manifest" select="..."/>. But that should not cause the problem you describe.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old February 26th, 2010, 10:02 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Like Martin, I can't see anything wrong beyond the oddities mentioned. But you haven't shown us the whole picture, e.g. what template rules are being invoked by the xsl:apply-templates, or whether there are any namespace declarations lurking in the code that you snipped.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
bonekrusher (February 26th, 2010)
 
Old February 26th, 2010, 10:08 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Thanks Martin and Michael.

The issue was in how I was calling the variable. The fix is:

Code:
<xsl:variable name="dm.manifest.doc">
        <xsl:copy-of select="$dm.manifest"/>
</xsl:variable>
Now I can access all the nodes, for example:

Code:
<xsl:value-of select="$dm.manifest.doc//modelic"/>
Thanks for the help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
key() not working within variable defined as temporary document baseliner XSLT 5 July 18th, 2009 03:42 PM
Creating a "WORD" document in ASP mcinar Classic ASP Components 9 April 10th, 2007 08:13 AM
creating temporary tables instead of queries clwk Access VBA 4 March 12th, 2007 02:50 PM
Creating a html in an xsl document allenatmarc XSLT 2 June 16th, 2004 04:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.