Double-Transformation in one pass?

T

tthunder

Hi @all,

Currently I am using Docbook with the XSLT style definition attached
below. However, this is really a XSLT issue/question!

Now I want to define a new tag for my DocBook xml file, say
"<my_special_requirement>". YES, it is not DocBook any more then, but
whatever.

What I want to do is writing that:

<my_special_requirement>
Test
</my_special_requirement>

BUT it should be processed (by the DocBook Stylesheets) like

<warning><title>A Warning</title>
Test
</warning>

(BTW: I don't wanna use workarounds like the "role" attribute. Please
no arguments, I am really curious and only interested in the question
I asked for, and not in workarounds... if it is not possible, it is
not possible, of course)

Thank you!
Kirsten

-----------------------------

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'
xmlns="http://www.w3.org/TR/xhtml1/transitional"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="#default">

<!-- HTML Output: -->
<xsl:import href="docbook/html/docbook.xsl"/>

<!-- HTML Templates: -->
<xsl:template match="my_special_requirement">
<!-- Hmhh... what to do here... that's what I asked for -->
</xsl:template>

<!-- Docbook Stylesheet Settings -->
<xsl:variable name="generate.toc"></xsl:variable>
<xsl:variable name="html.stylesheet.type">text/css</xsl:variable>
<xsl:variable name="html.stylesheet" select="'psl_doc.css'"></
xsl:variable>
<xsl:variable name="use.extensions" select="'1'"></xsl:variable>

</xsl:stylesheet>
 
J

Joe Kesselman

Doing two passes in a single stylesheet is possible, by doing an initial
transformation into a variable and then processing from that to the
output. In XSLT 1.0 you need the exslt nodeset extension to convert the
Result Tree Fragment back into a Nodeset so it can be transformed; in
XSLT 2.0 the needless distinction between RTFs and Nodesets was removed
and no special effort is needed; you just apply-templates to the
variable and the right thing happens.

A websearch should find examples of this; if you need help let me know
and I'll dig one up.


However... I don't understand why you think you need two passes in order
to accomplish your stated goal. Why not just add a template for the
<my_special_requirement> element which does the right thing?
 
T

tthunder

Doing two passes in a single stylesheet is possible, by doing an initial
transformation into a variable and then processing from that to the
output. In XSLT 1.0 you need the exslt nodeset extension to convert the
Result Tree Fragment back into a Nodeset so it can be transformed; in
XSLT 2.0 the needless distinction between RTFs and Nodesets was removed
and no special effort is needed; you just apply-templates to the
variable and the right thing happens.

A websearch should find examples of this; if you need help let me know
and I'll dig one up.

However... I don't understand why you think you need two passes in order
to accomplish your stated goal. Why not just add a template for the
<my_special_requirement> element which does the right thing?

Thanks for your help! This is a good idea and I will think and test in
this way...

Your question:

I really wished, I could add a template to do the right thing. But
what is the right thing?

The right thing is what the the DocBook stylesheets would do with

<warning><title>A Warning</title>
Test
</warning>

Maybe, I will change my mind and I define: the right thing is what the
DocBook stylesheets would do with

<note><title>*****AN INVENTION*****</title>
Test
</note>

You know... DocBook should do it, not me. It is my black box! What I
would need is a kind of calling mechanism
<my_special_requirement>xxx</my_special_requirement> => (should call
DocBook stylesheet functionality)
<warning><title>A Warning</title>xxx</warning>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top