Problem with doc-available...
Added by Anonymous over 14 years ago
Legacy ID: #8172823 Legacy Poster: Steve Horne (shhquiet)
I am trying to create multiple output files, but there could be more than one node being processed that result in the same output file. I am trying to avoid attempting to create the same file twice (see XSL below). I am getting the following error (using Saxon-HE 9.2.0.6J from Saxonica: [code] Error on line 1 column 1 of SimpleBacker_Wrapper.java: SXXP0003: Error reported by XML parser: Content is not allowed in prolog. Error at xsl:result-document on line 114 of createFolders.xslt: XTDE1490: Cannot write more than one result document to the same URI: file:/C:/PMABGen/java/com/dst/hps/pmab/ui/SimpleBacker_Wrapper.java at xsl:apply-templates (file:/C:/ws/pmab/PMABWebUI/src/main/resources/com/dst/hps/pmab/navdata/createFolders.xslt#95) processing /navigation-broker/navigationResources[1]/resourceGroup[1]/resourceGroup[1]/resource[2] [/code] XSL snippet: [code] <xsl:template match="resource" mode="backingClass"> <xsl:variable name="javaURI" select="resolve-uri(concat('file:///PMABGen/java/',replace(@backingBeanClass,'.','/'),'_Wrapper.java'))"/> <xsl:variable name="nameParts" select="tokenize(@backingBeanClass, '\s*.\s*')"/> <xsl:if test="not(doc-available($javaURI))"> <xsl:result-document href="{$javaURI}" format="text"> <xsl:call-template name="generateJava"> <xsl:with-param name="baseName" select="$nameParts[count($nameParts)]"/> </xsl:call-template> </xsl:result-document> </xsl:if> </xsl:template> [/code]
Replies (2)
RE: Problem with doc-available... - Added by Anonymous over 14 years ago
Legacy ID: #8172856 Legacy Poster: Michael Kay (mhkay)
You can't use doc-available() to test the existence of a file written by the transformation: the language doesn't allow this. Remember that the language isn't procedural, so things don't necessarily happen in the order you expect; all the result documents could conceivably be written in parallel. You need to find some other way of generating a unique filename for each output document. It seems to me that some kind of grouping on the value of @backingBeanClass would solve the problem.
RE: Problem with doc-available... - Added by Anonymous over 14 years ago
Legacy ID: #8172937 Legacy Poster: Steve Horne (shhquiet)
Thanks for your speedy reply-- I was afraid you were going to say that :( I think I can do as you suggest and the refactoring won't be too horrible...
Please register to reply