I have a piece of XML data which I need to transform into WML.
It's something like this:
<root>
<category name="music"/>
<subcategory name="classic"/>
<subcategory name="rock"/>
<subcategory name="Techno"/>
<node type="music" subtype="classic" name="beethoven"/>
<node type="music" subtype="classic" name="chopin"/>
<record author="beethoven" name="moonlight sonata"/>
…
</root>
I cannot change the file structure.
Some Nokia mobile browsers cannot load lots of <card>'s into memory.
So, depending on the mobile browser, the WML page should be either a whole set of <card>'s, or some subset of <card>'s.
For instance, if I download a page with a normal browser, it should look like this:
<wml>
<card id="TOC">
<p><a href="#contents">Contents</a></p>
<p><a href="#az">A-Z</a></p>
</card>
<card id="contents">
<p><a href="#music">music</a></p>
<p><a href="#video">video</a></p>
<p><a href="#java">java</a></p>
</card>
<card id="az">
<p><a href="#beethoven">beethoven</a></p>
<p><a href="#chopin">chopin</a></p>
</card>
<card id="music">
<p><a href="#classic">classic</a></p>
<p><a href="#rock">rock</a></p>
<p><a href="#Techno">Techno</a></p>
</card>
<card id="classic">
<p><a href="#beethoven">beethoven</a></p>
<p><a href="#chopin">chopin</a></p>
</card>
…
</wml>
, so that the user can browse without extra round-trips to the server.
However, when I use Nokia and visit the start page, the page should look like this:
http://example.com/
<wml>
<card id="TOC">
<p><a href="#contents">Contents</a></p>
<p><a href="#az">A-Z</a></p>
</card>
<card id="contents">
<p><a href="#music">music</a></p>
<p><a href="#video">video</a></p>
<p><a href="#java">java</a></p>
</card>
<card id="az">
<p><a href="/beethoven">beethoven</a></p>
<p><a href="/chopin">chopin</a></p>
</card>
<card id="music">
<p><a href="/classic">classic</a></p>
<p><a href="/rock">rock</a></p>
<p><a href="/Techno">Techno</a></p>
</card>
<card id="video">
<p><a href="/movies">Movies</a></p>
</card>
<card id="java">
<p><a href="/games">Games</a></p>
</card>
</wml>
, when I visit the href, it should show the inner contents:
http://example.com/classic
<wml>
<card id="TOC">
<p><a href="#contents">Contents</a></p>
<p><a href="#az">A-Z</a></p>
</card>
<card id="contents">
<p><a href="/music">music</a></p>
<p><a href="/video">video</a></p>
<p><a href="/java">java</a></p>
</card>
<card id="az">
<p><a href="#beethoven">beethoven</a></p>
<p><a href="#chopin">chopin</a></p>
</card>
<card id="classic">
<p><a href="#beethoven">beethoven</a></p>
<p><a href="#chopin">chopin</a></p>
</card>
…
</wml>
Basically, the XSLT should do the following things:
Accept some kind of a parameter of what is to be shown: the category, the subcategory etc.
Count the
<card>'s that would be shown.- If we load only types and TOC, we get
2cards (we always show them) - If we load only types and subtypes, we get
10cards. - If we load types, subtypes and titles, we show
100cards. - If we load everything, we show
300cards.
Nokiacannot handle more than120cards, so we just stop on level3.If
XMLchanges and level3requires130cards, we should stop on level2.- If we load only types and TOC, we get
Don't show a
<card>if it is below certain levelReplace the
#(inner links) with/(outer links) if the card is not to be shown.
Is it possible to do in a single XSL file?