Writing output to a 'log' file from within xsl:result-document

Discussion in 'XML' started by super.raddish@gmail.com, Jun 22, 2007.

  1. Guest

    Greetings one and all,

    I have a single source XML file and I am parsing the "records" within
    it into separate XML files using xsl:result-document. All that works
    fine. I am using the Saxon engine and I am supplying the .Transform()
    with a Target File path which it is using to create an empty file (as
    it is currently unused). So I end up with, say, 50 new XML flies and 1
    empty XML file at the path of the Target File

    <stylesheet>
    <!-- context of Target File -->
    <for-each loop>
    <xsl:result-document href="file(n)">
    <!-- context of New File (n) -->
    <!-- Write output to New File ... -->
    </xsl:result-document>
    </for-each loop>
    </stylesheet>

    What I want to be able to do is write to the Target File context from
    within the <xsl:result-document> context.

    <stylesheet>
    <!-- context of Target File -->
    <for-each loop>
    <xsl:result-document href="file(n)">
    <!-- context of New File (n) -->
    <!-- Write output to New File ... -->
    <!-- Write message to Target File ... -->
    </xsl:result-document>
    </for-each loop>
    </stylesheet>

    The XSL file I am using (as an example) is below. Does anyone have any
    suggestions or is this simply impossible. I have thought about using
    <xsl:message> and capturing the output but I want this to be fully
    self contained in the XSLT if it can be.

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0">
    <xsl:param name="outputPath" />
    <xsl:variable name="dataMapping"
    select="document('DataMapping.xml')" />
    <xsl:key name="oceans" match="mapsection[@name='oceans']/
    entry" use="@clientname" />
    <xsl:template match="/">
    <xsl:for-each select="main/datarecord">
    <xsl:result-document href="file:///{$outputPath}-
    {count(ancestor::node()|preceding::*)}.xml" >
    <updateRecord>
    <family><xsl:value-of select="species" /></family>
    <genus><xsl:value-of select="subspecies" /></genus>
    <habitat>
    <xsl:variable name="clientHabitat" select="location" />
    <xsl:for-each select="$dataMapping">
    <xsl:value-of select="key('oceans', $clientHabitat)/
    @internalname"/>
    </xsl:for-each>
    </habitat>
    <fullname><xsl:value-of select="name" /></fullname>
    </updateRecord>
    </xsl:result-document>
    </xsl:for-each>
    </xsl:stylesheet>

    Any help or advice greatly appreciated

    Al
     
    , Jun 22, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VG9tIFdpbmdlcnQ=?=

    My.Log.Writeexception not writing to Application Event Log.

    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,394
    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=
    Jan 20, 2006
  2. unomystEz
    Replies:
    0
    Views:
    568
    unomystEz
    Nov 19, 2006
  3. sqad
    Replies:
    1
    Views:
    3,590
  4. Tom Wingert
    Replies:
    0
    Views:
    347
    Tom Wingert
    Jan 12, 2006
  5. Michael Tan
    Replies:
    32
    Views:
    1,021
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page