Re: [xsl] Spread a ul/li list in several columns

Subject: Re: [xsl] Spread a ul/li list in several columns
From: Bernie <berniecc@xxxxxxxxx>
Date: Wed, 14 Nov 2007 17:02:19 +0100
Here I go,

<!-- XML START ========================================== -->

<?xml version='1.0' encoding='UTF-8'?>
<webmap>
  <section id='200'>
   <label lang='es_ES'
href='asociaciones/asociaciones_es_ES.html'><![CDATA[Asociaciones]]></label>
      <section id='202'>
        <label lang='es_ES'
href='asociaciones/APA/APA_es_ES.html'><![CDATA[Asociaciones padres
A.P.A]]></label>
      </section>
      <section id='201'>
        <label lang='es_ES'
href='asociaciones/autoayuda/autoayuda_es_ES.html'><![CDATA[Asociaciones
de autoayuda]]></label>
      </section>
  </section>
  <section id='3'>
       <label lang='es_ES'
href='ayuntamiento/ayuntamiento_es_ES.html'><![CDATA[Tu
Ayuntamiento]]></label>
      <section id='30'>
        <label lang='es_ES'
href='ayuntamiento/agenda/agenda_es_ES.html'><![CDATA[Agenda del
Alcalde]]></label>
      </section>
      <section id='29'>
        <label lang='es_ES'
href='ayuntamiento/alcalde/alcalde_es_ES.html'><![CDATA[El
Alcalde]]></label>
      </section>
  </section>
  <section id='26'>
   <label lang='es_ES'
href='deportes/deportes_es_ES.html'><![CDATA[Hacer Deporte]]></label>
      <section id='174'>
        <label lang='es_ES'
href='deportes/Clubs/Clubs_es_ES.html'><![CDATA[Clubs]]></label>
      </section>
      <section id='173'>
        <label lang='es_ES'
href='deportes/ColabsPatrons/ColabsPatrons_es_ES.html'><![CDATA[Colaboradores
y Patrocinadores]]></label>
      </section>
   </section>
  <section id='179'>
   <label lang='en_UK'
href='VisitaVillarrobledo/VisitaVillarrobledo_en_UK.html'><![CDATA[Visit
Villarrobledo]]></label>
      <label lang='es_ES'
href='VisitaVillarrobledo/VisitaVillarrobledo_es_ES.html'><![CDATA[Visita
Villarrobledo]]></label>
      <section id='192'>
        <label lang='en_UK'
href='VisitaVillarrobledo/Artesania/Artesania_en_UK.html'><![CDATA[Craftwork]
]></label>
        <label lang='es_ES'
href='VisitaVillarrobledo/Artesania/Artesania_es_ES.html'><![CDATA[Artesanma]
]></label>
      </section>
      <section id='185'>
        <label lang='en_UK'
href='VisitaVillarrobledo/Carnaval/Carnaval_en_UK.html'><![CDATA[Carnival]]><
/label>
        <label lang='es_ES'
href='VisitaVillarrobledo/Carnaval/Carnaval_es_ES.html'><![CDATA[El
Carnaval]]></label>
      </section>
   </section>
</webmap>

<!-- XML END ========================================== -->
<!-- XSL START ============================================== -->

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" encoding="utf-8" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
	<xsl:param name="lang">en_UK</xsl:param>

  <xsl:template match="/webmap/section">

    <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Web Map</title>
    </head>

  <body>
	  <div style="clear:both;float:left;*float:none;width:100%;">
		  <div class="divWebMapCol" style="clear:both;">

      		<!-- PUT XSL CODE HERE FOR 2 COLUMN WEBMAP LINKS -->

                 </div>
	       <!-- divWebMapCol -->
        </div>

  </body>
  </html>
  </xsl:template>

<xsl:template match="section">
    <xsl:if test="label!=''">
        <xsl:if test="count(ancestor::*)=2">
            <li class="liRombo">
                <xsl:apply-templates select="label" />
          	</li>
        </xsl:if>
        <xsl:if test="count(ancestor::*)!=2">
            <li class="liOrangeDots">
                <xsl:apply-templates select="label" />
    	      </li>
        </xsl:if>
    	<ul>
    		<xsl:apply-templates select="section" />
    	</ul>
    </xsl:if>
  </xsl:template>

<xsl:template match="label">
 <xsl:choose>
    <xsl:when test="@lang=$lang">
      <xsl:call-template name="labelLink" />
    </xsl:when>
    <xsl:when test="count(../label)=1">
      <xsl:call-template name="labelLink" />
    </xsl:when>

 </xsl:choose>
</xsl:template>

<xsl:template name="labelLink">
  <xsl:choose>
    <xsl:when test="@href!=''">
      <a>
  		<xsl:attribute name="href">
  			<xsl:value-of select="@href" />
  			</xsl:attribute>
  		  <xsl:value-of select="." />
  	  </a>
    </xsl:when>
    <xsl:otherwise>
  		  <xsl:value-of select="." />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>

<!-- XSL END ============================================== -->

Note:

The resulting HTML code to be inserted in the mentioned place, should be:

<!-- HTML START =========================================== -->

<div style="float:left;clear:both;width:50%">
  <ul>
    <li class="liRombo">
      <a href="asociaciones/asociaciones_es_ES.html">Asociaciones</a>
    </li>
    <ul>
      <li class="liOrangeDots">
        <a href="asociaciones/APA/APA_es_ES.html">Asociaciones padres
A.P.A</a>
      </li>
      <li class="liOrangeDots">
        <a href="asociaciones/autoayuda/autoayuda_es_ES.html">Asociaciones
de autoayuda</a>
      </li>
    </ul>
    <li class="liRombo">
      <a href="ayuntamiento/ayuntamiento_es_ES.html">Tu Ayuntamiento</a>
    </li>
    <ul>
      <li class="liOrangeDots">
        <a href="ayuntamiento/agenda/agenda_es_ES.html">Agenda del
Alcalde</a>
      </li>
      <li class="liOrangeDots">
        <a href="ayuntamiento/alcalde/alcalde_es_ES.html">El Alcalde</a>
      </li>
    </ul>
  </ul>
</div>

<div style="float:left;width:50%">
  <ul>
    <li class="liRombo">
      <a href="deportes/deportes_es_ES.html">Hacer Deporte</a>
    </li>
    <ul>
      <li class="liOrangeDots">
        <a href="deportes/Clubs/Clubs_es_ES.html">Clubs</a>
      </li>
      <ul></ul>
      <li class="liOrangeDots">
        <a
href="deportes/ColabsPatrons/ColabsPatrons_es_ES.html">Colaboradores
y Patrocinadores</a>
      </li>
    </ul>
    <li class="liRombo">
      <a href="VisitaVillarrobledo/VisitaVillarrobledo_en_UK.html">Visit
Villarrobledo</a>
    </li>
    <ul>
      <li class="liOrangeDots">
        <a
href="VisitaVillarrobledo/Artesania/Artesania_en_UK.html">Craftwork</a>
      </li>
      <ul></ul>
      <li class="liOrangeDots">
        <a
href="VisitaVillarrobledo/Carnaval/Carnaval_en_UK.html">Carnival</a>
      </li>
    </ul>
  </ul>
</div>

<!-- HTML END =================================== -->

Thank you!
Bernie.


On Nov 14, 2007 4:43 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> Then, as Tommie says, you need to tell us what the inputs and outputs of
> your transformation are.
>
> MK
>
> > -----Original Message-----
> > From: Bernie [mailto:berniecc@xxxxxxxxx]
>
> > Sent: 14 November 2007 14:50
> > To: Michael Kay
> > Subject: Re: [xsl] Spread a ul/li list in several columns
> >
> > It does not intend to be an HTML question for I build the
> > UL-LI code from an XML by XSL sentences. I'd like to know how
> > can I distribute first level UL blocks into different DIVs.
> >
> > Thank you.
> > Bernie.
> >
> > On Nov 14, 2007 3:36 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > >  This looks like an HTML question to me - if it's an XSLT question
> > > then you'd better clarify or Tommie will be down on you
> > like a ton of bricks.
> > >
> > > MK
> > >
> > >
> > > > -----Original Message-----
> > > > From: Bernie [mailto:berniecc@xxxxxxxxx]
> > > > Sent: 14 November 2007 14:29
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: [xsl] Spread a ul/li list in several columns
> > > >
> > > > How can I split a two level "UL" "LI" lists into two or
> > three HTML
> > > > columns (Liquid layout DIVs)?
> > > >
> > > > First level ULs must keep their children.
> > > >
> > > > Thank you.
> > > > Bernie.

Current Thread
  • [xsl] Spread a ul/li list in several columns
    • Bernie - Wed, 14 Nov 2007 15:29:18 +0100
      • Message not available
        • Message not available
      • Message not available
        • Message not available
          • Message not available
          • Bernie - Wed, 14 Nov 2007 17:02:19 +0100 <=
          • Bernie - Wed, 14 Nov 2007 17:42:15 +0100
          • Steve - Wed, 14 Nov 2007 11:48:20 -0500