Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a new parameter $intermediate-docbook-uri #441

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/guide/xml/ch04.xml
Original file line number Diff line number Diff line change
Expand Up @@ -595,15 +595,15 @@ Oxygen change markup processing instructions.
</listitem>
</orderedlist>

<para>A customization can introduce transformations to the original
document: before the standard transformations by specifying them in
<parameter>transform-original</parameter>; after the standard transformations
but before the transformation to HTML by specifying them in
<parameter>transform-before</parameter>; or after the HTML transformation
by specifying them in <parameter>transform-after</parameter>. (If you need
to insert a transformation in the middle of the standard transformations,
you’ll have to update the <varname>v:standard-transforms</varname>
variable.)</para>
<para>A customization can introduce transformations to the original document: before the standard
transformations by specifying them in <parameter>transform-original</parameter>; after the
standard transformations but before the transformation to HTML by specifying them in
<parameter>transform-before</parameter>; or after the HTML transformation by specifying them
in <parameter>transform-after</parameter>. (If you need to insert a transformation in the
middle of the standard transformations, you’ll have to update the
<varname>v:standard-transforms</varname> variable.) If you want to see the normalized and
augmented DocBook content just before the conversion to HTML starts, you can use the
<parameter>intermediate-docbook-uri</parameter> parameter.</para>

<note>
<para>Transformations in <varname>transform-after</varname> will be processing
Expand Down
32 changes: 32 additions & 0 deletions src/guide/xml/ref-params.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,38 @@ of the entries for each section. This results in a more complete index while
still preserving the ability to see in which sections the terms occur.</para>
</refsection>
</refentry>

<refentry>
<refmeta>
<fieldsynopsis>
<type>xs:string</type>
<varname>intermediate-docbook-uri</varname>
<initializer>''</initializer>
</fieldsynopsis>
</refmeta>
<refnamediv>
<refpurpose>URI for intermediate DocBook content</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>If the parameter is not empty, a file with the content of the input document to which
the following transformations have been applied is written to the specified location: </para>
<orderedlist>
<listitem>
<para>transformations from <parameter>transform-original</parameter>, if any;</para>
</listitem>
<listitem>
<para>standard transformations (see <varname>v:standard-transforms</varname>);</para>
</listitem>
<listitem>
<para>transformations from <parameter>transform-before</parameter>, if any.</para>
</listitem>
</orderedlist>
<para>It is the normalized and augmented DocBook content immediatly before transformations
into HTML begins. If the URI is relative, it will be resolved against the base-input
documents <code>base-uri(/)</code>.</para>
</refsection>
</refentry>

<refentry>
<refmeta>
Expand Down
35 changes: 28 additions & 7 deletions src/main/xslt/docbook.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:db="http://docbook.org/ns/docbook"
xmlns:dbe="http://docbook.org/ns/docbook/errors"
xmlns:err='http://www.w3.org/2005/xqt-errors'
xmlns:ext="http://docbook.org/extensions/xslt"
xmlns:f="http://docbook.org/ns/docbook/functions"
xmlns:fp="http://docbook.org/ns/docbook/functions/private"
Expand Down Expand Up @@ -203,13 +204,33 @@
map { xs:QName('vp:starting-base-uri'): $starting-base-uri })"/>
</xsl:variable>

<!--
<xsl:result-document href="/tmp/out.xml" method="xml" indent="yes">
<xsl:apply-templates select="$document" mode="m:docbook">
<xsl:with-param name="vp:loop-count" select="1" tunnel="yes"/>
</xsl:apply-templates>
</xsl:result-document>
-->
<xsl:if test="$intermediate-docbook-uri gt ''">
<xsl:try>
<xsl:variable name="intermediate-docbook-href" as="xs:anyURI">
<xsl:choose>
<xsl:when test="
(starts-with($intermediate-docbook-uri, 'file:')
or starts-with($intermediate-docbook-uri, '/')
or matches($intermediate-docbook-uri,'[A-Z]:','i'))
and $intermediate-docbook-uri castable as xs:anyURI">
<xsl:sequence select="xs:anyURI($intermediate-docbook-uri)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="resolve-uri($intermediate-docbook-uri, base-uri(/))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:result-document href="{$intermediate-docbook-href}" method="xml" indent="no" exclude-result-prefixes="#all">
<xsl:copy-of select="$document" copy-namespaces="no"/>
</xsl:result-document>
<xsl:message select="'Wrote intermediate DocBook content to file ' || $intermediate-docbook-href"/>
<xsl:catch>
<xsl:message
select="'Cannot write intermediate DocBook to ' || $intermediate-docbook-uri || ': ' || $err:description"
/>
</xsl:catch>
</xsl:try>
</xsl:if>

<xsl:variable name="result" as="document-node()">
<xsl:call-template name="t:chunk-cleanup">
Expand Down
Loading