xsl-list
[Top] [All Lists]

[xsl] Keeping result-document() from writing to a file more than once?

2019-04-18 16:56:13

I'm processing some DITA xml files with XSLT. I'm reading these files
and where they have a conref into some other content (think xinclude)
that is included in the current file. There may be multiple things
shared out from one large file (topic). I want to make a new file for
each of the shared pieces.
 
 More than one file can reference exactly the same content, so after
processing all these files I want a single file representing the
shared content. It is this multiple references to the same content
that causes the duplication of the file that the result-document()
function doesn't like. this is the code that I have for detecting this
situation:
 
 <xsl:variable name="newFile" select="concat($srcFile, '-', $target,
'-output.dita')" />
 
 
 
 NEW FILE <xsl:value-of select="$newFile"/> 
 
 Doc available: <xsl:value-of select="doc-available($newFile)"/> 
 
 
 <xsl:if test="not(doc-available($newFile))" 
 
 CREATE FILE NOW 
 
 <xsl:result-document method="xml" href="{$newFile}" indent="yes">
 <referable-content id="ikj1555615661716" xml:lang="en-us">
 <titler>efereable test</title>
 <rcbody>
 <xsl:copy-of select="document($srcFile)//*[@id = $target]"/>
 </rcbody>
 </referable-content>
 </xsl:result-document>
 
 </xsl:if>
 
 
 
 
 
 Here are a series of messages created as i process the files. Notice
that the first message correctly identifies the file
"conref-para_content.dita-simpletable_nohead-output.dita" as not
existing and produces output. If you then look at the last one you
will see the same file being referenced and tries to write to the file
again. But in other places you see the test working properly and not
creating a new file:
 
 
 
 
 
 file 'conref-para_content.dita' 
 NEW FILE
/Users/danvint/pubsrc-other/formatting-sample/conref-para_content.dita-simpletable_nohead-output.dita
 Doc available: false'
 
 CREATE FILE NOW
 
 file 'conref-para_content.dita' 
 NEW FILE
/Users/danvint/pubsrc-other/formatting-sample/conref-para_content.dita-simpletable_head-output.dita
 Doc available: true'
 
 file 'conref-para_content.dita' 
 NEW FILE
/Users/danvint/pubsrc-other/formatting-sample/conref-para_content.dita-table_head-output.dita
 Doc available: true'
 
 file 'conref-para_content.dita' 
 NEW FILE
/Users/danvint/pubsrc-other/formatting-sample/conref-para_content.dita-table_nohead-output.dita
 Doc available: true'
 
 file 'conref-para_content.dita' 
 NEW FILE
/Users/danvint/pubsrc-other/formatting-sample/conref-para_content.dita-simpletable_nohead-output.dita
 Doc available: false'
 
 CREATE FILE NOW
 
 
 
I believe the doc-available() reads the file to be XML. So when the
script stops there is a file in the OS but it is empty due to the
second write failing. Running this in oXygen I get the results of what
should have been written showing up in a window. I cut and pasted that
content into the empty file and reran it. Processing got further along
and stopped on a second file with the same message. I did the same
thing, with the new content in this second file and it now runs to
completion if all the files exist.

If I delete all the files that were generated, I'm back to the same
problem. Is there some delay in writing the output that I should  be
accounting for? Is there a sleep() function in XSLT or something to
cause a delay or flush the buffer?
 
 Any ideas on what I can check?
 
 
 
 ..dan
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>