xsl-list
[Top] [All Lists]

RE: [xsl]Problem with Position()?

2007-10-14 07:32:47
 

Is this strictly true Michael? I've had some success 
assigning input to keys for later use.

I assume you're questioning the bit about having to process some input
twice? Well, I did wonder about elaborating that, but I didn't want to
overcomplicate the message. It is true, of course, that if you have to
process the input twice then there are techniques available such as keys and
variables to save repeating all the work each time. But the main point of
the message was: structure the code according to the structure of the
output.

Michael Kay
http://www.saxonica.com/


On Oct 13, 2007, at 2:30 PM, Michael Kay wrote:

You need to organize your code according to the structure of the 
output you want to produce, not according to the structure of the 
input (that's why it's called a "template"). In this case, 
this means 
producing the attributes of a node before its children. In other 
cases, it means producing the children in the right order. If this 
means you have to process some input twice (perhaps in different 
modes), then that's what you have to do.

Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Alice Ju-Hsuan Wei [mailto:ajwei(_at_)indiana(_dot_)edu]
Sent: 13 October 2007 22:16
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl]Problem with Position()?

Dear Michael and all:

   Thanks, and when I "commented" out that line, it works.
But, how am supposed to generate something like <p class="(some 
attribute"> followed by the text to format the content if I cannot 
use <xsl:call-template> here? The template portion is at 
the bottom.

Thanks again.


Alice

<xsl:template match="collection">
   <div><p/>
            <span class="character">
               <xsl:apply-templates 
select="id(@recorder)"/> </span> 
</div> </xsl:template>

<xsl:template match="book">
<div>
  <xsl:apply-templates select="./@author"/>,
  <i><xsl:apply-templates select="./@title"/></i>.
   (<xsl:apply-templates select="./@topic"/>)
   [  <xsl:apply-templates/>]
           </div>
  </xsl:template>

<xsl:template match="p">
       <xsl:choose>

           <xsl:when test="count(preceding-sibling::p) != 1">

               <xsl:call-template name="rend"/>
               <xsl:apply-templates/>

           </xsl:when>
           <xsl:otherwise>

               <p>
                   <xsl:call-template name="rend"/>
                   <xsl:apply-templates/>
               </p>

           </xsl:otherwise>
       </xsl:choose>
   </xsl:template>

<xsl:template name="rend">
        <xsl:attribute name="class">
            <xsl:value-of select="./@rend"/>
        </xsl:attribute>
    </xsl:template>



Quoting Michael Kay <mike(_at_)saxonica(_dot_)com>:

   I have commented everything in my document except for these 
sections,

That can't be true. At the very least there must be a named
template
called "rend", or it wouldn't run at all. I think Ken is almost 
certainly right, that it's your processing of the @topic
attribute that's at fault.

Michael Kay
http://www.saxonica.com/




--~------------------------------------------------------------------
XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>