[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Help with xsl:result-document

Subject: Re: Help with xsl:result-document
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 25 Oct 2010 17:24:46 -0400
Re:  Help with xsl:result-document
At 2010-10-25 22:09 +0100, Neil Owens wrote:
I've come to an impasse with trying to use xsl:result-document. I have a number of XML log files that I'm trying to extract data from and place that data into a database. I think it best to have 4 tables - OutCommand, InResponse, InCommand and OutResponse. To ease my SQL bulk import coding, I thought to produce 4 output files from one XSLT2.0 transform. However, I just can't figure out how to get result-document to work with my obvious limited knowledge of transforms. I'm looking to get 4 output files - OutCommandoutput.xml, InResponse-output.xml, InCommand-output.xml and OutResponse-output.xml. But I can't use templates, as I've more than one 'match' - and so the template tries (and obviously fails) to create another output stream to something it's already created. But I can't see a way out of this, so any advice, pointers or help will be, as ever, appreciated.

Thankfully, this has a straightforward repair.


Where you now have:

<xsl:template match="MyLog">
    <xsl:element name="Device">
        <xsl:apply-templates select="OutCommand"/>
        <xsl:apply-templates select="InResponse"/>
        <xsl:apply-templates select="InCommand"/>
        <xsl:apply-templates select="OutResponse"/>
    </xsl:element>
</xsl:template>

<xsl:template match="OutCommand">
<xsl:result-document method="xml" href="OutCommandoutput.xml">
    <OutCommand>
...
    </OutCommand>
</xsl:result-document>
</xsl:template>

<xsl:template match="InResponse">
<xsl:result-document method="xml" href="InResponse-output.xml">
    <InResponse>
...
    </InResponse>
</xsl:result-document>
</xsl:template>

<xsl:template match="InCommand">
<xsl:result-document method="xml" href="InCommand-output.xml">
    <InCommand>
...
    </InCommand>
</xsl:result-document>
</xsl:template>

<xsl:template match="OutResponse">
<xsl:result-document method="xml" href="OutResponse-output.xml">
    <OutResponse>
...
    </OutResponse>
    </xsl:result-document>
</xsl:template>


... change that to be:


<xsl:template match="MyLog">
        <xsl:result-document method="xml" href="OutCommandoutput.xml">
          <xsl:apply-templates select="OutCommand"/>
        </xsl:result-document>
        <xsl:result-document method="xml" href="InResponse-output.xml">
          <xsl:apply-templates select="InResponse"/>
        </xsl:result-document>
        <xsl:result-document method="xml" href="InCommand-output.xml">
          <xsl:apply-templates select="InCommand"/>
        </xsl:result-document>
        <xsl:result-document method="xml" href="OutResponse-output.xml">
          <xsl:apply-templates select="OutResponse"/>
        </xsl:result-document>
</xsl:template>

<xsl:template match="OutCommand">
    <OutCommand>
...
    </OutCommand>
</xsl:template>

<xsl:template match="InResponse">
    <InResponse>
...
    </InResponse>
</xsl:template>

<xsl:template match="InCommand">
    <InCommand>
...
    </InCommand>
</xsl:template>

<xsl:template match="OutResponse">
    <OutResponse>
...
    </OutResponse>
</xsl:template>


I hope this helps.


. . . . . . . . Ken

--
XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.