Re: Store non-well-formed HTML fragment

Thanks, Jim, for the pointer.

However, the link discusses a different scenario: I don't want to output text/plain but instead content type text/html instead.

Hence, one can't use output method "text", since all markup get's lost:

Consider this example:
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
    <p:input port="source">
        <p:empty/>
    </p:input>
    <p:output port="result">
        <p:pipe port="result" step="store"/>
    </p:output>
    <p:identity>
        <p:input port="source">
            <p:inline>
<c:data type="text/plain">
<div>
    Test&amp;
</div>
<p>
    Test&#160;
</p>
</c:data>
            </p:inline>
        </p:input>
    </p:identity>
    <p:store name="store" href="test.html" method="text" encoding="utf-8" media-type="text/plain" />
</p:declare-step>

This produces:

    Test&


    Test 

[with some whitespace surrounded]

You see, all markup is skipped. Also escaping the markup doesn't solve the problem, since also entities are escaped. Moreover, generally the problem with method "text" is that indentation cannot be applied.

I'd expect this to work like:
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
    <p:input port="source">
        <p:empty/>
    </p:input>
    <p:output port="result">
        <p:pipe port="result" step="store"/>
    </p:output>
    <p:identity>
        <p:input port="source">
            <p:inline>
<div>
    Test&amp;
</div>
<p>
    Test&#160;
</p>
            </p:inline>
        </p:input>
    </p:identity>
    <p:store name="store" href="test.html" method="html" encoding="utf-8" media-type="text/html" version="4.01" />
</p:declare-step>

And the expected output would be:
<div>
    Test&amp;
</div>
<p>
    Test&#160;
</p>

Again, with plain XSLT it's no problem to just store not well-formed xml (with more than one root element) to a file. So maybe XProc should also be aligned with XSLT regarding this? In my scenario it is not acceptable to solely store single rooted HTML snippets. Hence, this simple use case would opt-out XProc over plain XSLT, which is somehow disappointing :(

Anyone else for a solution/suggestions? 

Thanks! 


On 03.06.2013, at 08:45, James Fuller <james.fuller.2007@gmail.com> wrote:

> take a look at this recent thread
> 
> http://lists.w3.org/Archives/Public/xproc-dev/2013May/0005.html
> 
> hth, Jim Fuller
> 
> On Sun, Jun 2, 2013 at 1:40 PM, Vivian Steller <vivian@steller.info> wrote:
>> Dear all,
>> is there any way to serialize non-well-formed HTML using p:store?
>> Particularly, I'm trying to store an HTML fragment that does not have a
>> single root node. While this works with plain XSL result-documents, XProc
>> fails with the following error:
>> 
>> "XD0001 : XD0001 It is a dynamic error if a non-XML resource is produced on
>> a step output or arrives on a step input."
>> 
>> This is the full pipeline:
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>> xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
>>    <p:input port="source">
>>        <p:empty/>
>>    </p:input>
>>    <p:output port="result">
>>        <p:pipe port="result" step="store"/>
>>    </p:output>
>>    <p:xslt name="xsl">
>>        <p:input port="source">
>>            <p:inline>
>>                <test/>
>>            </p:inline>
>>        </p:input>
>>        <p:input port="parameters">
>>            <p:empty/>
>>        </p:input>
>>        <p:input port="stylesheet">
>>            <p:inline>
>>                <xsl:stylesheet
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
>>                    <xsl:template match="/">
>>                        <xsl:result-document href="test.snippet.xml"
>> indent="yes" omit-xml-declaration="yes" method="xml"
>> exclude-result-prefixes="#all">
>>                            <div>
>>                                Test
>>                            </div>
>>                            <p>
>>                                Test
>>                            </p>
>>                        </xsl:result-document>
>>                    </xsl:template>
>>                </xsl:stylesheet>
>>            </p:inline>
>>        </p:input>
>>    </p:xslt>
>>    <p:sink>
>>        <p:input port="source">
>>            <p:pipe port="result" step="xsl"/>
>>        </p:input>
>>    </p:sink>
>>    <p:store name="store" href="test.html">
>>        <p:input port="source">
>>            <p:pipe port="secondary" step="xsl"/>
>>        </p:input>
>>    </p:store>
>> </p:declare-step>
>> 
>> Any help is appreciated.
>> Cheers,
>> 
>> Vivian
>> 
> 

Received on Monday, 3 June 2013 10:40:54 UTC