W3C home > Mailing lists > Public > xproc-dev@w3.org > June 2010

Reading doctype-public and doctype-system from xsl:output

From: Jostein Austvik Jacobsen <josteinaj@gmail.com>
Date: Mon, 14 Jun 2010 16:03:04 +0200
Message-ID: <AANLkTikaYuKDiTi9_bnPksPMSw6akPkAwT3EmS48OrMv@mail.gmail.com>
To: xproc-dev@w3.org

How can I use the DTD defined in the doctype, where the doctype is defined
in a xsl:output in a p:xslt step, to validate and p:store the resulting XML?
Here's some code to demonstrate my problem:

---- begin input.xml ----
<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE document SYSTEM "http://www.idunn.no/dtd/document1.5_Idunn.dtd">
            <title>Hello XProc!</title>
            <para>Hello XProc!</para>
---- end input.xml ----

---- begin transform.xsl ----
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mf="
http://example.com/2009/mf" exclude-result-prefixes="xs mf" xmlns="

        Here I specify the doctype, and I would assume that it carried
through to the XProc script, however that seems not to be the case.
    <xsl:output method="xml" version="1.0" doctype-public="-//NISO//DTD
dtbook 2005-2//EN" doctype-system="
http://www.daisy.org/z3986/2005/dtbook-2005-2.dtd" encoding="utf-8"/>

    <xsl:template match="document">
        <dtbook xmlns="http://www.daisy.org/z3986/2005/dtbook/"
version="2005-2" xml:lang="no">
            <book showin="blp">
                <xsl:apply-templates select="contentSection"/>
    <xsl:template match="contentSection">
    <xsl:template match="para">

---- end transform.xsl ----

---- begin pipe.xpl ----
<?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" primary="true">
        <p:document href="input.xml"/>

    <p:xslt version="1.0">
        <p:input port="parameters">
        <p:input port="stylesheet">
            <p:document href="transform.xsl"></p:document>

    <!--  How would I validate the XML here? I would prefer to use the DTD
        in the output from the XSLT transformation instead of explicitly
        a URL to it: -->
    <!-- <p:validate-with-xml-schema/> -->

    <p:store href="dtbook.xml">
            If I don't specify the doctype as options here, then the
            document doesn't get a <!DOCTYPE ...>. I would like to pass
            the doctype from the XSLT-transformation here.
        <p:with-option name="encoding" select="'UTF-8'"/>
        <p:with-option name="doctype-public" select="'-//NISO//DTD dtbook
        <p:with-option name="doctype-system" select="'

---- end pipe.xpl ----

---- begin dtbook.xml ----
<!DOCTYPE dtbook PUBLIC "-//NISO//DTD dtbook 2005-2//EN" "
<dtbook xmlns="http://www.daisy.org/z3986/2005/dtbook/" version="2005-2"
  <book showin="blp">
        <h1>Hello XProc!</h1>
        <p>Hello XProc!</p>
---- end dtbook.xml ----

The pipe.xpl-script takes input.xml as input, applies transform.xsl on it
and stores the result as dtbook.xml. The code, as shown, should be all valid
and run without errors, resulting in dtbook.xml (see comments in the code.)
I'm using oXygen/Calabash.

Best regards
Jostein Austvik Jacobsen
Received on Monday, 14 June 2010 15:58:55 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:53 UTC