This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Selecting templates by root elements from input (sub-) docs


Hi,

I have several XML input documents each representing one chapter or
section (with a root element accordingly named "chapter" or "section")
of a bigger structure, so they sometimes happen to be a kind of
logical subdoc of the main input document that is currently processed.

In a rather complex stylesheet, I'm reading the content of each of
those subdoc files by using the document() function. My goal is to
process that content using a template specific to "chapter" or
"section".

As I mentionned in a previous posting with the subject "Parameter
evaluation after use of document()", I try to find the appropriate
template for the document by passing its whole content, in my
"subdoc_mode" mode specialized to that processing step. As I need the
subdoc's name when processing it, I am also passing that parameter (a
global parameter):

  <xsl:apply-templates
    select="document($my_subdoc)"
    mode="subdoc_mode">
    <!-- hand the param to the called template -->
    <xsl:with-param name="my_subdoc"
      select="$my_subdoc"/>
  </xsl:apply-templates>

Unfortunately, my parameter gets lost - even after passing it
explicitly like this!

>From Oleg Tkachenko's response to my posting I learnt that losing a
parameter may be related to selecting the document's root NODE instead
of its root ELEMENT - or any other element form the document -, as the
built-in template matching "/" would certainly lose it, so I added
that instruction. He also recommended:

Oleg> Try to add some location path after document() function to
eliminate
Oleg> built-in templates processing as they don't pass parameters.

I tried with appending "/*" to the document() instruction, but to no
avail. Of course it would be possible to explicitly select "/chapter"
or "/section", but I think I cannot do without a generic
"apply-templates" instruction like the one above - it would thus not
be possible to state the document's root element.

Do you have any suggestions? Maybe on the general topic of processing
subdocs?

  Yves

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]