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]

Modes and .//something (2 questions)


Hello,

There's something I don't understand. Well, there
are a lot of things I don't understand and this is one
of them.

Right now I have about 50 to 100 input documents
to run through the XSLT processor one after the
other. Eventually there could be as many as 15 or
20,000.

In certain circumstances, there is an element that
I would be inserting during transformation, that will
have an attribute whose value is dependent on a certain
characteristic of the entire input document. So I
first need to look through the whole document to
determine this characteristic, then go through it
again to do the actual transformation. Since there
are going to be a lot of documents to look at, I
would prefer to be able to do this with only one
invocation of the XSLT processor per document, rather
than two each.

To begin with, I am trying to do this with a mode
for the first pass. But I suspect I am misunderstanding
the nature of XSLT evaluation.

Here are the first few templates of my stylesheet,
(with an extension call removed from the second
template, as it's too much detail to show here).
I've put in the messages to try to figure out what's
happening.


<xsl:template match="/">
     <xsl:message>Hello there</xsl:message>
   <xsl:apply-templates mode="scanIDs"/>
     <xsl:message>Between there</xsl:message>
   <xsl:apply-templates/>
     <xsl:message>Goodbye there</xsl:message>
</xsl:template>

<xsl:template mode="scanIDs" match=".//channel">
   <xsl:message>Matched channels in scanIDs</xsl:message>
</xsl:template>

<xsl:template mode="scanIDs" match="*">
<xsl:message>Other stuff</xsl:message>
</xsl:template>



The third template seemed to be necessary; before I
added it I got some of the blanks and tabs in the
input document, copied to the output, and I don't
want anything copied in the first pass.

What I see on my console for each input document is

Hello there
Other stuff
Goodbye there

AND I get an indication that the other no-mode templates
(not shown) do get matched on.

My questions are:

a) I need to have the "scanIDs" finished before the
no-mode templates run. Is it true that I cannot rely
on what order the statements in the first template
are executed? In that case I would have to use
two XSLT processor invocations after all.

b) There are a number of <channel> elements in my
input documents. But I never see the message from
my second template. How should I rewrite the
XPath on that one, to match all of the <channels>?
Or is the "*" template gobbling up everything
before the ".//channel" one can get at it?

Thanks very much,
Michael Oltz


 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]