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

Problems with xsl:result-document (result doc already

Subject: Problems with xsl:result-document (result doc already created implicitly or explicitly)
From: Luis A Ortiz <luis@xxxxxxxxxxxxxxxx>
Date: Fri, 28 Aug 2009 14:15:54 -0400
 Problems with xsl:result-document (result doc already
Hi List,
I'm looking for help with a problem I am having writing a series of XML files using xsl:result-document. When I comment out the xsl:result-document and simply write out the path and names of the files I am trying to write out, I see no duplicates but with the xsl:result-document is uncommented, it always returns the error message "A result document with this href has already been implicitly or explicitly created".


As I said, I dont see duplicate filenames when I am simply writing out the hrefs. I am also wrapping the xsl:result-document in an xsl:if test="boolean(doc-available($pagefile-path)) = false()" though I understand that wouldnt work anyhow.

Im sure that my pattern for doing this is wrong, but I have tried a few variations with the same problem. I have some html files with content that I break out and copy to separate xml files Each of the html files will become 1 or more xml files.

I have a file called structure.xml that lists out each of the xml files that I wish to create, and there is enough information in there for me to locate the source html file. Everything seems to work ok except when I try to create the files with result-document resulting in "A result document with this href has already been implicitly or explicitly created". The contents of the file doesnt seem to matter.

I am using XMLSpy 09 Pro (Win7 64bit), and the built-in XSLT engine. I tried to use saxon9he.jar however cant get that working ("'java' is not recognizable as an internal or external command" though I did install Java SE Runtime env.).

My XSL:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" />


<xsl:variable name="folder-source">D:\Projects\Data Manipulation\phase2\contentA</xsl:variable>
<xsl:variable name="folder-target">D:\Projects\Data Manipulation\phase2\contentC</xsl:variable>


<xsl:template match="/">
<info>
   <xsl:apply-templates select="/structure/section/chapter/tutorial/page"/>
</info>
</xsl:template>

<xsl:template match="page">
<xsl:variable name="page-number" select="./@number" />
<xsl:variable name="chapter-number" select="../../@number" />
<xsl:variable name="section-number" select="../../../@number" />
<xsl:variable name="tutorialfile-path" select="concat($folder-source,'\chapter',$chapter-number,'\ch_',$chapter-number,'_tutorial.html')"/>
<xsl:variable name="pagefile-path" select="concat($folder-target,'\',./@src)" />
<xsl:call-template name="writepagefile">
<xsl:with-param name="section-number" select="$section-number"/>
<xsl:with-param name="chapter-number" select="$chapter-number"/>
<xsl:with-param name="page-number" select="$page-number"/>
<xsl:with-param name="tutorialfile-path" select="$tutorialfile-path"/>
<xsl:with-param name="pagefile-path" select="$pagefile-path"/>
</xsl:call-template>
</xsl:template>



<xsl:template name="writepagefile">
<xsl:param name="section-number"/>
<xsl:param name="chapter-number"/>
<xsl:param name="page-number"/>
<xsl:param name="tutorialfile-path"/>
<xsl:param name="pagefile-path"/>
<xsl:variable name="source-page-start-node" select="document($tutorialfile-path)/html/body/p[.='[page]'][$page-number]"/>
--would like to create file: <xsl:value-of select="$pagefile-path"/>--
<xsl:if test="boolean(doc-available($pagefile-path)) = false()">
+ and I think this should b fine +
<xsl:result-document href="$pagefile-path" method="xml">
<page section="{$section-number}" chapter="{$chapter-number}" number="{$page-number}">
<xsl:copy-of select="$source-page-start-node/following-sibling::*[generate-id(following-sibling::p[.='[page]'][1]) = generate-id(current()/following-sibling::p[.='[page]'][1])]"></xsl:copy-of> <!-- unrelated but I know this part can be improved. Source is flattened, with <p>[page]</p> nodes separating the chunks I want to write out to separate files -->
</page>
</xsl:result-document>
</xsl:if>
</xsl:template>



Sample of my XML:
<?xml version="1.0" encoding="UTF-8"?>
<structure>
<pretest name="Basic Math Pretest" src="pretest.xml"/>
<section number="1" name="Mathematics Review">
<chapter number="1" name="Fractions and Decimals ">
<tutorial>
<page number="1" src="ch1\tutorial_page1.xml"/>
<page number="2" src="ch1\tutorial_page2.xml"/>
<page number="3" src="ch1\tutorial_page3.xml"/>
</tutorial>
<quiz name="Fractions and Decimals " src="ch1\quiz1.xml"/>
</chapter>
<chapter number="2" name="Ratios, Percents, Simple Equations, and Ratio-Proportion ">
<tutorial>
<page number="1" src="ch2\tutorial_page1.xml"/>
<page number="2" src="ch2\tutorial_page2.xml"/>
<page number="3" src="ch2\tutorial_page3.xml"/>
</tutorial>
<quiz name="Ratios, Percents, Simple Equations, and Ratio-Proportion " src="ch2\quiz1.xml"/>
</chapter>
</section>
</structure>


I did try to find a solution in the archives. Many thanks!

Luis

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-2011 All Rights Reserved.