This is the mail archive of the
docbook@lists.oasis-open.org
mailing list for the DocBook project.
Re: [docbook] mediaobject fileref troubles
[this is more of a docbook-apps@lists.oasis-open.org post, but the
original post and question was mainly about the input thus the thread
should be appropriate for docbook@lists.oasis-open.org]
Hi Patrick,
you could also use XSLT 2.
If you want to continue to use the current docbook.sf.net XSLTs, you
could resolve references to external files in a simple preprocessing step.
For example, you could run your sources through something like
<xsl:transform
version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform">
<template match="node() | @*">
<copy>
<apply-templates select="@* | node()" />
</copy>
</template>
<template match="textdata[@fileref]">
<!--
I'm sure there is a much simpler way
-->
<variable name="dir_abs"
select="replace(base-uri(/),'[^\/]+$','')"/>
<!--
AFAICS, basically resolve-uri()
concatenates if @fileref is relative, and
leaves unchanged if it's absolute
-->
<variable name="file_abs"
select="resolve-uri(@fileref,$dir_abs)"/>
<copy-of select="unparsed-text($file_abs,'utf-8')"/>
</template>
</transform>
The template works for me (Saxon 7.5.1), but the whole XSLT has not been
run or tested.
See an example at
http://www.pinkjuice.com/joocs/doc/ (URL will change)
(currently last test, #14)
Input:
http://www.pinkjuice.com/joocs/test/input.dbx
<section><title>Inserted File</title>
<example><title>Counter</title>
<programlisting><textobject><textdata
fileref="counter.rb"/></textobject></programlisting>
</example>
</section>
Output:
http://www.pinkjuice.com/joocs/test/output.xhtml
<div class="section jcs-toplevel">
<h3 class="title">Inserted File</h3>
<!-- example not yet fully supported -->
<h3 class="title">Counter</h3>
<pre><code>1.upto(ARGV[0].to_i) do |i|
puts i
end
</code></pre>
</div>
Program:
http://www.pinkjuice.com/joocs/xslt/
http://www.pinkjuice.com/joocs/xslt/prel_main.xslt
(also see above)
Tobi
--
http://www.pinkjuice.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-help@lists.oasis-open.org