xsl-list
[Top] [All Lists]

Re: Re: Check if text is before an tag or not

2003-11-13 01:58:44
Hi Jeni (and other helpers),

thanks alot for your help!!

everything works just perfect now!
And... I have still another week left...whiiii...

This worked (if other people like to know how it works):
<xsl:template match="title">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="name">
  <xsl:variable name="nrEntrada"
                select="ancestor::itemInv/@n" />
  <a href="JavaScript:authorWindow('{$inventario}',{$nrEntrada});"
     class="linkAuthor">
    <xsl:value-of select="." />
  </a>
</xsl:template>

<xsl:template match="title/text()[1]">
  <xsl:value-of select="." />
  <xsl:if test="following-sibling::name"> - </xsl:if>
</xsl:template>

<xsl:template match="title/text()[last()]">
  <xsl:if test="preceding-sibling::name"> - </xsl:if>
  <xsl:value-of select="." />
</xsl:template>

And indeed, like you said whitespace and punctuation is a matter for the 
XML-editor itself. I'll tell him :-D.

To bad I don't know you, but I'd buy you all a drink!

Thanks alot!!!

Greetings
Sebastien Deprez

ps: the $inventario is a parameter given to the xsl, so nothing to worry about 
;-).
it's the inventory-nummer (cause there are more then one ;-))
------------------------
 xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com wrote:
------------------------
        
Hi Sebastien,

XML:


   
     fol. 13v 
     
     Séneca 
     y 
     Cicerón 
      en castellano de los oficios 
      
    

[snip]
The output should be:
Séneca y Cicerón - de los oficios

It's not clear how this output is derivable from the XML that you've
given above. How do you know to only output "de los oficios" and not
"en castellano de los oficios"?

The obvious output from the above XML is:

 Séneca y Cicerón en casstellano de los oficios

(with the names clickable). You can get this with something like:


 



 
 
   
 


(Note that I'm not sure where the value of $inventario comes from.)

It sounds as though you want a hyphen to be added after the first text
node in  if it's got a following  sibling, and before the
last text node in  if it's got a preceding  sibling. You
can do this with the following two templates:


 
  - 



  - 
 


This will give you (roughly):

 Séneca y Cicerón - en casstellano de los oficios

(Personally I think it's good practice to have mixed content contain
exactly the punctuation and whitespace that you want to have, rather
than letting it be added by a stylesheet later. Rules for adding
punctuation and whitespace in mixed content are horrible to maintain.)
 
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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




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



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