[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Transforming xml to tex

Subject: Re: Transforming xml to tex
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 16 Jul 2008 22:30:48 +0200
Re:  Transforming xml to tex
Hi Michael,

In your code below you don not show:

 1. What XSLT version you are using
 2. What the non-standard function sintax:convert does
 3. What the context node is

This makes it quite hard to help you with your problem. The question itself is rather trivial to answer though, but that doesn't seem to fit in the (rather imperative -- try to be more declarative!) code, yet might be a good pointer:

<xsl:template match="glossterm
     [following-sibling::text()]
     [following-sibling::text()
        [translate(substring(., 1, 1), ',;.:?!(){}[]-', '') = '' ]] ">

  <xsl:text>}</xsl:text>
</xsl:template>

The translate() function is used here to find out whether one of your characters is there. That's just a bit easier than a bunch of starts-with() statements.

HTH,
Cheers,
-- Abel --


Michael Obermeier wrote:
Hello,

I need some help with xslt. I try to transform xml to tex and all is working
except for one point. I have a paragraph tag and inside this a glossary tag
like this: <p>here is the text <glossterm>glossary term</glossterm> more
text</p>

I need to know if there is a punctuation mark after the glossary tag.
I tried following:

  <xsl:variable name="text">
         <xsl:value-of select="normalize-space(syntax:convert(parent::*))"/>
  </xsl:variable>

  <xsl:variable name="glossaryterm">
         <xsl:value-of select="normalize-space(syntax:convert(.))"/>
  </xsl:variable>

  <xsl:variable name="testFall">
        <xsl:value-of select="substring-after($text,$glossaryterm)"/>
  </xsl:variable>
        <xsl:choose>
     <xsl:when test="starts-with($testFall,',') or
starts-with($testFall,';') or starts-with($testFall,'.') or
starts-with($testFall,':') or starts-with($testFall,'?') or
starts-with($testFall,'!') or starts-with($testFall,'(') or
starts-with($testFall,')') or starts-with($testFall,'{') or
starts-with($testFall,'}') or starts-with($testFall,'[') or
starts-with($testFall,']') or starts-with($testFall,'-')">
       <xsl:text>}</xsl:text>
     </xsl:when>
     <xsl:otherwise>
       <xsl:text>} </xsl:text>
     </xsl:otherwise>
   </xsl:choose>

This works only if the $glossaryterm appears only (or at least primarily)
inside the glossterm. Otherwise the $testFall contains not want I need.

Has anybody an idea how I can get the first character after the glossterm.

Many thanks

Michael

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.