[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] flatten tree


Subject: Re: [xsl] flatten tree
From: Jan Limpens <jan.limpens@xxxxxxxxx>
Date: Mon, 20 Sep 2004 11:31:09 -0300

hi michael, group,

unfortunately I do not get the expected results (actually nothing
changed). probably time to send in the original xslt/xml/output

<?xml version="1.0"?>
<xsl:stylesheet xmlns:lc="http://limpens.com/blogbase"
exclude-result-prefixes="lc" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes" encoding="utf-8"/>
	<xsl:param name="selectedLanguage" select="'en'"/>
	<xsl:param name="defaultLanguage" select="'en'"/>
	<xsl:template match="*">
		<xsl:if test="@lang = $selectedLanguage or ((not(@lang) and
$defaultLanguage = $selectedLanguage))">
			<xsl:apply-imports/>
		</xsl:if>
	</xsl:template>
	<xsl:template match="/">
		<div id="BlogDiv">
			<xsl:apply-templates select="lc:Blog"/>
		</div>
	</xsl:template>
	<xsl:template match="lc:Blog">
		<xsl:apply-templates
select="lc:BlogInfos/lc:BlogInfo[@lang=$selectedLanguage]"/>
		<xsl:for-each select="lc:Entries/lc:Entry">
			<xsl:sort select="substring(@pubdate,1,4)" order="descending"/>
			<!-- year  -->
			<xsl:sort select="substring(@pubdate,6,2)" order="descending"/>
			<!-- month -->
			<xsl:sort select="substring(@pubdate,8,2)" order="descending"/>
			<!-- day   -->
			<xsl:apply-templates select="lc:Version[@lang=$selectedLanguage or
@lang=$defaultLanguage]"/>
		</xsl:for-each>
		<div style="height:1px; clear:both">&#160;</div>
	</xsl:template>
	<xsl:template match="lc:BlogInfo">
		<div id="IntroDiv">
			<h1>
				<xsl:value-of select="lc:Title"/>
			</h1>
			<p>
				<xsl:value-of select="lc:Description"/>
			</p>
		</div>
	</xsl:template>
	<xsl:template match="lc:Version">
		<xsl:variable name="link">Entry.aspx?Entry=<xsl:value-of
select="../@id"/></xsl:variable>
		<div class="EntryDiv">
			<div class="EntryHeader">
				<p>
					<xsl:apply-templates select="../@pubdate"/>
				</p>
				<h2>
					<xsl:value-of select="lc:Title"/>
				</h2>
			</div>
			<div class="EntryBody">
				<p>
					<a href="{$link}">
						<xsl:apply-templates select="../lc:Thumbnail"/>
					</a>
					<xsl:value-of select="lc:Body/lc:Para[1]"/>
					<br/>
					<a href="{$link}">
						<xsl:variable name="info"
select="document('../LanguageDefinitions.xml')/Definitions/Language[@shorthan
d=$selectedLanguage]/ClickHereForMoreInfo"/>
						<img src="Images/Style/Stripes/MoreInfo.gif" alt="{$info}"/>
					</a>
				</p>
			</div>
		</div>
	</xsl:template>
	<xsl:template match="@pubdate">
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="lc:Thumbnail">
		<img src="{@src}" alt="Thumbnail:
{../lc:Version[@lang=$selectedLanguage]/lc:Title}" class="Thumbnail"/>
	</xsl:template>
</xsl:stylesheet>

with

<?xml version="1.0"?>
<Blog xmlns="http://limpens.com/blogbase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://limpens.com/blogbase Schemas/BlogBase.xsd">
<BlogInfos>
	<BlogInfo lang="pt">
		<Title>Ilustragues e outros trabalhos graficos</Title>
		<Description>Uma lista de meus trabalhos de ilustragco</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>
<Entries>
	<Entry pubdate="1997-01-15T00:00:00" id="WaldeckCovers">
		<Version lang="pt">
			<Title>Capas de disco para o ginio de rock - Waldeck</Title>
			<Body>
				<Para>Uma outra capa para o musico vienense Waldeck.</Para>
			</Body>
		</Version>
		<Version lang="de">
			<Title>Covers for the incredible genius of Rock - Waldeck</Title>
			<Body>
				<Para>Das zweite Cover f|r den Wiener Szene Act Waldeck.</Para>
				<Para>Es zeigt einen Subnauten bei einem untergegangenen
Flugzeugwrack.</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/Icon_IEditora-Promo-Comic-2.png"/>
	</Entry>
	<Entry pubdate="1995-01-15T00:00:00" id="ClubFlyers">
		<Version lang="pt">
			<Title>Desenho de Flyers</Title>
			<Body>
				<Para>Uma Variedade de Flyers para clubes de danga vienenses
durante a epoca do ticno. Destacam se os flyers do Otakoo Saloon, um
clube que eu fiz com varios amigos com motivos de Kung Fu e cinema de
agco do Hong Kong, durante uma epoqua quando John Woo aindo ss
tarabalhava no HK.</Para>
			</Body>
		</Version>
		<Version lang="de">
			<Title>Flyers f|r Wiener Clubs</Title>
			<Body>
				<Para>Eine Auswahl an Flyern, die ich f|r Wiener Clubs wdrend der
Bl|tezeit des Technos designt habe.</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/Icon_IEditora-Promo-Comic-2.png"/>
	</Entry>
	<Entry pubdate="2000-01-01T00:00:00" id="AfroBabe">
		<Version lang="en">
			<Title>Afrobabe Book Cover</Title>
			<Body>
				<Para>A book cover for a title that until now didn't find an
editor, which is, by the way, a shame. Still it's nice to look
at.</Para>
			</Body>
		</Version>
		<Version lang="de">
			<Title>Afrobabe Book Cover</Title>
			<Body>
				<Para>Das Buch zu diesem Cover ist zwar leider nie erschienen, was
einigermassen schade ist. Nichts desto trotz hat es einen
interessanten, pulpigen Stil und war meine erste Illustration im
engeren Sinne.</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/TeaserIllustrationsAfrobabe.gif"/>
	</Entry>
	<Entry pubdate="2003-01-01T00:00:00" id="CheckPointNewMediaIllustrations">

		<Version lang="en">
			<Title>Presentation Illustrations</Title>
			<Body>
				<Para>To be able to better communicate their ideas of how to spice
up a stadium with latest high-tech gadgets, I was contacted by an
agency. See some of my output here.</Para>
			</Body>
		</Version>

		<Version lang="de">
			<Title>Prdsentation Illustrationen</Title>
			<Body>
				<Para>To be able to better communicate their ideas of how to spice
up a stadium with latest high-tech gadgets, I was contacted by an
agency. See some of my output here.</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/TeaserIllustrationsCheckPointMedia.gif"/>
				<Slideshow>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenBadger.png">
			<ImageInfo lang="en">
				<Title>Madge, your badge!</Title>
				<Description>Visitors get badges to identify themselves and their
activities throughout the building.</Description>
			</ImageInfo>
		</Image>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenEmotometer.png">
			<ImageInfo lang="en">
				<Title>Emotometer</Title>
				<Description>Visitors of concerts can express themselves by
triggering their own light show.</Description>
			</ImageInfo>
		</Image>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenHall.png">
			<ImageInfo lang="en">
				<Title>SMS Panels</Title>
				<Description>Visitors can send SMS Messages to wallmounted
displays.</Description>
			</ImageInfo>
		</Image>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenReferee.png">
			<ImageInfo lang="en">
				<Title>Tame The Team</Title>
				<Description>Visitors participate in interactive games using only
motion tracking.</Description>
			</ImageInfo>
		</Image>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenSpielBar.png">
			<ImageInfo lang="en">
				<Title>Games At The Bar</Title>
				<Description>Cocktail tables with embedded displays allow
gambling. The game reacts to input by objects placed on the
screen.</Description>
			</ImageInfo>
		</Image>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenScreen.png">
			<ImageInfo lang="en">
				<Title>Backprojected Infosystem</Title>
				<Description>Reacts to touch</Description>
			</ImageInfo>
		</Image>
		<Image src="Images/Slideshows/CheckPointNewMedia/ScreenStelen.png">
			<ImageInfo lang="en">
				<Title>Sound Guidance Systems</Title>
				<Description>Helps finding your event and, afterwards the
car.</Description>
			</ImageInfo>
		</Image>
		</Slideshow>
	</Entry>
	<Entry pubdate="2003-02-01T00:00:00" id="UhudlMoviePoster">
		<Version lang="en">
			<Title>Uhudl Movie Poster and Dvd Booklet</Title>
			<Body>
				<Para>For the premiere of the first Casa Del Kung Fu full length
motion picture I drafted this poster, due to insufficient funds it
never was printed, though...</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/illust1.jpg"/>
	</Entry>
	<Entry pubdate="2003-03-01T00:00:00" id="ZobiePoster">
		<Version lang="en">
			<Title>Ghastly Zombies</Title>
			<Body>
				<Para>Some spooky drawings that help a zombie festival's poster to
look more fiendish. If you think you are strong and old enough, you
may risk a peek ... but beware!</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/TeaserIllustrationsZombies.gif"/>
	</Entry>
	<Entry pubdate="2003-04-01T00:00:00" id="iEditoraComics">
		<Version lang="en">
			<Title>Promo Comic</Title>
			<Body>
				<Para>IEditora, a Brazilian Self-Publishing Company now promotes
its product using a nice comic strip I did for them. Have a look at it
here.</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/teaser_ieditora_promo.gif"/>
	</Entry>
	<Entry pubdate="2003-05-01T00:00:00" id="MarjorieJoanaTag">
		<Version lang="en">
			<Title>Marjorie e Joana Tag</Title>
			<Body>
				<Para>For the Brazilian Fashion Designer Marjorie Gueller and
Joana Porto I designed these tags to properly represent their
collection.</Para>
			</Body>
		</Version>
		<Thumbnail src="Images/Thumbnails/illust3.gif"/>
	</Entry>
	</Entries>
</Blog>

transorms to

	<?xml version="1.0" encoding="utf-8"?>
<div id="BlogDiv">
  <div id="IntroDiv">
    <h1>Illustrationen und andere grafische Arbeiten</h1>

    <p>Eine chronologische Auflistung aller Arbeiten, die ich in den
letzten Jahren als Illustrator und Graphic Designer realisiert
habe.</p>
  </div>
  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2003-05-01T00:00:00</p>
      <h2>Marjorie e Joana Tag</h2>
    </div>

    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=MarjorieJoanaTag">
          <img src="Images/Thumbnails/illust3.gif" alt="Thumbnail: "
class="Thumbnail" />
        </a>For the Brazilian Fashion Designer Marjorie Gueller and
Joana Porto I designed these tags to properly represent their
collection.<br /><a href="Entry.aspx?Entry=MarjorieJoanaTag"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>
  <div class="EntryDiv">

    <div class="EntryHeader">
      <p>2003-04-01T00:00:00</p>
      <h2>Promo Comic</h2>
    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=iEditoraComics">
          <img src="Images/Thumbnails/teaser_ieditora_promo.gif"
alt="Thumbnail: " class="Thumbnail" />

        </a>IEditora, a Brazilian Self-Publishing Company now promotes
its product using a nice comic strip I did for them. Have a look at it
here.<br /><a href="Entry.aspx?Entry=iEditoraComics"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>
  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2003-03-01T00:00:00</p>
      <h2>Ghastly Zombies</h2>

    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=ZobiePoster">
          <img src="Images/Thumbnails/TeaserIllustrationsZombies.gif"
alt="Thumbnail: " class="Thumbnail" />
        </a>Some spooky drawings that help a zombie festival's poster
to look more fiendish. If you think you are strong and old enough, you
may risk a peek ... but beware!<br /><a
href="Entry.aspx?Entry=ZobiePoster"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>

  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2003-02-01T00:00:00</p>
      <h2>Uhudl Movie Poster and Dvd Booklet</h2>
    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=UhudlMoviePoster">

          <img src="Images/Thumbnails/illust1.jpg" alt="Thumbnail: "
class="Thumbnail" />
        </a>For the premiere of the first Casa Del Kung Fu full length
motion picture I drafted this poster, due to insufficient funds it
never was printed, though...<br /><a
href="Entry.aspx?Entry=UhudlMoviePoster"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>
  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2003-01-01T00:00:00</p>
      <h2>Presentation Illustrations</h2>

    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=CheckPointNewMediaIllustrations">
          <img src="Images/Thumbnails/TeaserIllustrationsCheckPointMedia.gif"
alt="Thumbnail: Prdsentation Illustrationen" class="Thumbnail" />
        </a>To be able to better communicate their ideas of how to
spice up a stadium with latest high-tech gadgets, I was contacted by
an agency. See some of my output here.<br /><a
href="Entry.aspx?Entry=CheckPointNewMediaIllustrations"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>

  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2003-01-01T00:00:00</p>
      <h2>Prdsentation Illustrationen</h2>
    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=CheckPointNewMediaIllustrations">

          <img src="Images/Thumbnails/TeaserIllustrationsCheckPointMedia.gif"
alt="Thumbnail: Prdsentation Illustrationen" class="Thumbnail" />
        </a>To be able to better communicate their ideas of how to
spice up a stadium with latest high-tech gadgets, I was contacted by
an agency. See some of my output here.<br /><a
href="Entry.aspx?Entry=CheckPointNewMediaIllustrations"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>
  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2000-01-01T00:00:00</p>
      <h2>Afrobabe Book Cover</h2>

    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=AfroBabe">
          <img src="Images/Thumbnails/TeaserIllustrationsAfrobabe.gif"
alt="Thumbnail: Afrobabe Book Cover" class="Thumbnail" />
        </a>A book cover for a title that until now didn't find an
editor, which is, by the way, a shame. Still it's nice to look at.<br
/><a href="Entry.aspx?Entry=AfroBabe"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>

  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>2000-01-01T00:00:00</p>
      <h2>Afrobabe Book Cover</h2>
    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=AfroBabe">

          <img src="Images/Thumbnails/TeaserIllustrationsAfrobabe.gif"
alt="Thumbnail: Afrobabe Book Cover" class="Thumbnail" />
        </a>Das Buch zu diesem Cover ist zwar leider nie erschienen,
was einigermassen schade ist. Nichts desto trotz hat es einen
interessanten, pulpigen Stil und war meine erste Illustration im
engeren Sinne.<br /><a href="Entry.aspx?Entry=AfroBabe"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>
  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>1997-01-15T00:00:00</p>
      <h2>Covers for the incredible genius of Rock - Waldeck</h2>

    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=WaldeckCovers">
          <img src="Images/Thumbnails/Icon_IEditora-Promo-Comic-2.png"
alt="Thumbnail: Covers for the incredible genius of Rock - Waldeck"
class="Thumbnail" />
        </a>Das zweite Cover f|r den Wiener Szene Act Waldeck.<br /><a
href="Entry.aspx?Entry=WaldeckCovers"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>

  <div class="EntryDiv">
    <div class="EntryHeader">
      <p>1995-01-15T00:00:00</p>
      <h2>Flyers f|r Wiener Clubs</h2>
    </div>
    <div class="EntryBody">
      <p>
        <a href="Entry.aspx?Entry=ClubFlyers">

          <img src="Images/Thumbnails/Icon_IEditora-Promo-Comic-2.png"
alt="Thumbnail: Flyers f|r Wiener Clubs" class="Thumbnail" />
        </a>Eine Auswahl an Flyern, die ich f|r Wiener Clubs wdrend
der Bl|tezeit des Technos designt habe.<br /><a
href="Entry.aspx?Entry=ClubFlyers"><img
src="Images/Style/Stripes/MoreInfo.gif" alt="Klicken Sie hier f|r
weitere Informationen" /></a></p>
    </div>
  </div>
  <div style="height:1px; clear:both"> </div>
</div>

for example the afrobabe entry comes twice, in english and german.

the only for-each I use for sorting the entries by date, but then
apply-template. should't the *  template render all other [@lang...]
clauses useless? but if I remove them, all versions are show. hmm. I
am not getting something here, am I?

thanks for the help

jan


Current Thread