xsl-list
[Top] [All Lists]

fallback parameter

2004-09-22 18:59:49
Hi folks,

I am still trying to bring this to work, but could not come up with
anything useful so far... (there is another thread for this problem
already, but it seems quite buried and forgotten, I hope very much you
don't mind for bringing this up again)

In my xml I have areas marked with lang='somelanguage'. In my xslt I
defined a parameter selectedLanguage (can be changed by user input)
and a parameter defaultLanguage, that is used, when no content in the
selected Language is available.

The problem is, that I cannot manage to bring this to work. As soon as
the selected language differs from the default one and there is an
entry in the selected language, I see both entries. If the selected
language has no corresponding area, it works as expected.

In the example the results are

defLang selLang Result
en              en              ok
en              de              not as expected
en              es              ok


I don't understand why this is so...

the xml looks like this:
   <BlogInfos>
      <BlogInfo lang="pt">
         <Title>Ilustrações e outros trabalhos gráficos</Title>
         <Description>Uma lista de meus trabalhos de ilustração</Description>
      </BlogInfo>
      <BlogInfo lang="de">
         <Title>Illustrationen und andere grafische Arbeiten</Title>
         <Description>Eine chronologische Auflistung aller Arbeiten,
die ich in den letzten Jahren als Illustrator und Graphic Designer
realisiert habe.</Description>
      </BlogInfo>
      <BlogInfo lang="en">
         <Title>Illustrations and other visual ventures</Title>
         <Description>Here you will find a wild mix of projects, jobs,
ideas, rants and everything that comes to my mind in this
category.</Description>
      </BlogInfo>
   </BlogInfos>

and the xslt like this:
        <xsl:param name="selectedLanguage" select="'de'"/>
        <xsl:param name="defaultLanguage" select="'en'"/>

<xsl:template match="lc:BlogInfo">
                <xsl:if test="@lang=$selectedLanguage or 
                (not(following-sibling[(_at_)lang=$selectedLanguage]) and
not(preceding-sibling[(_at_)lang=$selectedLanguage]) and
@lang=$defaultLanguage)">
                        <div id="IntroDiv">
                                <h1>
                                        <xsl:value-of select="lc:Title"/>
                                </h1>
                                <p>
                                        <xsl:value-of select="lc:Description"/>
                                </p>
                        </div>
                </xsl:if>
        </xsl:template>

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


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