- From: Jostein Austvik Jacobsen <josteinaj@gmail.com>
- Date: Mon, 14 Jun 2010 16:03:04 +0200
- To: xproc-dev@w3.org
- Message-ID: <AANLkTikaYuKDiTi9_bnPksPMSw6akPkAwT3EmS48OrMv@mail.gmail.com>
Hi. 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"> <document> <metaData> <title>Hello XProc!</title> <logicalTitle>ht-2009-4-1</logicalTitle> <description/> <language>no_NO</language> <commenting>off</commenting> <indexing>on</indexing> <subject/> <categoryPrimary/> <author> <firstName/> <lastName/> </author> <contentType>content_document_editorial</contentType> <colleague>false</colleague> </metaData> <contributors/> <contentSection> <para>Hello XProc!</para> </contentSection> </document> ---- 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=" http://www.daisy.org/z3986/2005/dtbook/"> <!-- 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"> <head/> <book showin="blp"> <xsl:apply-templates select="contentSection"/> </book> </dtbook> </xsl:template> <xsl:template match="contentSection"> <bodymatter> <level1> <h1><xsl:value-of select="/document/metaData[1]/title[1]"></xsl:value-of></h1> <xsl:apply-templates/> </level1> </bodymatter> </xsl:template> <xsl:template match="para"> <p><xsl:apply-templates/></p> </xsl:template> </xsl:stylesheet> ---- 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:input> <p:xslt version="1.0"> <p:input port="parameters"> <p:empty/> </p:input> <p:input port="stylesheet"> <p:document href="transform.xsl"></p:document> </p:input> </p:xslt> <!-- How would I validate the XML here? I would prefer to use the DTD specified in the output from the XSLT transformation instead of explicitly setting 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 resulting document doesn't get a <!DOCTYPE ...>. I would like to pass through 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 2005-2//EN'"/> <p:with-option name="doctype-system" select="' http://www.daisy.org/z3986/2005/dtbook-2005-2.dtd'"/> </p:store> </p:declare-step> ---- end pipe.xpl ---- ---- begin dtbook.xml ---- <!DOCTYPE dtbook PUBLIC "-//NISO//DTD dtbook 2005-2//EN" " http://www.daisy.org/z3986/2005/dtbook-2005-2.dtd"> <dtbook xmlns="http://www.daisy.org/z3986/2005/dtbook/" version="2005-2" xml:lang="no"> <head/> <book showin="blp"> <bodymatter> <level1> <h1>Hello XProc!</h1> <p>Hello XProc!</p> </level1> </bodymatter> </book> </dtbook> ---- 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