4

I just want to transform an input document (it's just a list of file references) to several output documents.

this works:

    <p:xslt name="MainTransformation1-b">
        <p:input port="source">
            <p:pipe step="CI" port="result"/>
        </p:input>
        <p:input port="stylesheet">
            <p:document href="Transform.xsl"/>
        </p:input>
        <p:with-param name="ProjectName" select="$Name"/>
    </p:xslt>

    <p:sink/>

    <p:for-each>
        <p:iteration-source>
            <p:pipe step="MainTransformation1-b" port="secondary"/>
        </p:iteration-source>
        <p:store method="text" media-type="text/text">
            <p:with-option name="href" select="p:base-uri()"/>
        </p:store>
    </p:for-each>

XSL:

<xsl:template match="/">
    <xsl:for-each select="//p">
        <xsl:result-document href="{'tmp', position(), '.xml'}">
            <xsl:apply-templates/>
        </xsl:result-document>
    </xsl:for-each>
</xsl:template>

problem: an output document doesn't contain a root element - I need to output frames and later on in the process a frame file is created and includes all output documents.

error message:

09.11.2012 13:06:27 com.xmlcalabash.util.DefaultXProcMessageListener error SCHWERWIEGEND: err:XD0001:XD0001 09.11.2012 13:06:27 com.xmlcalabash.drivers.Main error SCHWERWIEGEND: It is a dynamic error if a non-XML resource is produced on a step output or arrives on a step input.

Of course it's not XML - I tried to fix that on behalf of the @method (method=text), but it didn't worked.

Any ideas? I searched for applicable solutions, but I only found an entry saying that this won't be possible at the moment... Hopefully not

Oliver
  • 61
  • 3

1 Answers1

3

The input for p:store has to be XML. Wrap you text output of the transform in a wrapper element, and apply method=text on that, the wrapper element will be ignored automatically, so you will get your text/plain file..

HTH!

grtjn
  • 20,254
  • 1
  • 24
  • 35
  • Sorry for asking again - but I just added before of the for-each loop - but it still doesn't work. – Oliver Nov 20 '12 at 11:38
  • @grtijn I meet the same problem. My XSLT output pure-text by using . In XProc I invoke to execute that XSLT, but the error occured: "p:xslt returned non-XML result". Is there any way to workaround it? I dont want to wrapper a root element in XSLT, because I want to keep XSLT clean. The XSLT which output pure-text is my last step in XSLT. – chansey Feb 27 '18 at 16:25
  • I'm afraid XProc has been rather rigid in this respect, and not sure it has loosened up yet since all those years it first came out. It might be worth signing up for the xproc-dev mailing list, that way you should reach most people still involved: https://lists.w3.org/Archives/Public/xproc-dev/ – grtjn Feb 28 '18 at 10:34