xsl-list
[Top] [All Lists]

Re: fallback parameter

2004-09-23 06:09:32
There's in light! Ok, I must admit, I feel a bit ashamed not to have
seen this. It seems to be a typical beginner's mistake to try every
ugly hack to make a thing worked as  planned and to overlook all the
other simple options at the same time!

Thanks a lot guys!

--jan


On Wed, 22 Sep 2004 19:37:17 -0700, James A. Robinson
<jimr(_at_)highwire(_dot_)stanford(_dot_)edu> wrote:

Hi,

I'm sorry that I can't directly answer your question but I don't
understand the logic you are trying to lay out in your <xsl:if> test.
I understand what you want to do, I just don't see how you can accomplish
what you want. The reason is that, as far as I knew, when you have a
template matching BlogInfo, every single BlogInfo is going to be tested
and so as long as your default language exists it will always be true.
Forgive me if that's a stupid statement on my part. :(

I was hoping the stylesheet below might be of help?  It shows a simpler
logic flow, where at the top level, the BlogInfos level, you decide which
BlogInfo to display.  I don't know what constraints you are working under
w/re to the template matches, but I would hope you could make use of this.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="2.0">

  <xsl:param name="selectedLanguage" select="'de'"/>
  <xsl:param name="defaultLanguage" select="'en'"/>

  <xsl:template match="BlogInfos">
    <xsl:choose>
      <xsl:when test="./BlogInfo[(_at_)lang=$selectedLanguage]">
        <xsl:apply-templates select="BlogInfo[(_at_)lang=$selectedLanguage]"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="BlogInfo[(_at_)lang=$defaultLanguage]"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="BlogInfo">
    <div id="IntroDiv">
      <h1>
        <xsl:value-of select="Title"/>
      </h1>
      <p>
        <xsl:value-of select="Description"/>
      </p>
    </div>
  </xsl:template>

</xsl:stylesheet>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       
jim(_dot_)robinson(_at_)stanford(_dot_)edu
Stanford University HighWire Press      http://highwire.stanford.edu/
650-723-7294 (W) 650-725-9335 (F)




-- 
Jan
http://www.limpens.com


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