[sword-devel] Portuguese translation - request for help

Greg Hellings greg.hellings at gmail.com
Thu Sep 9 17:13:42 MST 2010

Greetings, Peter,

On Thu, Sep 9, 2010 at 5:52 PM, Peter von Kaehne <refdoc at gmx.net> wrote:
> Several questions re XSLT:
> How can I select on (bits of/features of) content of the actual text
> node - e.g. the text being capitalised?

Depending on the version of XSLT being used, there are certain
functions that can be used which are built-in to XSLT.  You would use
the fn: namespace to access them.

http://www.w3schools.com/xsl/xsl_functions.asp lists the ones that are
in XSLT 1.0 which every XSLT processor you use will have.
http://www.w3schools.com/xpath/xpath_functions.asp has the XSLT 2.0
functions, which most of your good quality XSLT processors will have.

There are some XSLT 3.0 functions, I think, but the support for those
will be more erratic than for XSLT 2.0.  (one caveat I've encountered
is that you must properly declare your version as 2.0 or 3.0 if you
want support for those functions, otherwise they will not be handled).

If none of the built-in functions fulfill your needs, you can always
provide custom extension functions you register.  Every good XSLT
processor should have the ability to call something like
fn:user_defined_func() which you then tie to a programming language's
function.  If you're calling, for instance, libxml2 from its Perl
bindings, you can register a custom Perl function to be executed every
time you want.  If you're using xsltproc or something like that,
you'll have to figure out how to hook in custom functions.  I have
used pyxsltproc in this way (it is xsltproc, written in python, using
libxml2's bindings) but it has been a while.

> How can I print out an attribute?

These are from memory, so forgive if I mess it up.  You would use the
<xsl:value-of select="{xpath}" /> element, and replace {xpath} with
the path to the attribute, appending the attribute name with @.  Given
the following XHTML snippet
  <a href="http://www.google.com">Google</a>
if your current context is the div, you would call <xsl:value-of
select="a/@href" />

> How can I avoid the text content being printed while still working on
> the children nodes?

To get the text content you use <xsl:value-of select="{xpath}" />.  To
process child nodes you would use <xsl:apply-templates select="*" />
That will not process the attributes of the current element.  To do
that as well you would want <xsl:apply-templates select="*|@*" />.

> I think i have made decent progress on this text, but there were long
> periods of inactivity until I understood the next steps.
> FWIW my process:

I think your process is good.  I don't know how you're applying the
stylesheets, but if you are comfortable using Perl's libxml2 bindings
or some other XML processing system, you could do all of that within a
single Perl script.  The only possible exception is pdf2xml - I don't
know if that has bindings.  Even if it doesn't, you could simply the
process to "pdf2xml file.pdf | ./monolithic.pl" if you would like.
There are drawbacks and benefits to doing it like that.  Just a


More information about the sword-devel mailing list