This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How dynamic is XSL?


Well... It seems like I cant have a template inside a template. How do I
then start and stop my XSL document, plus having some templates in between?

I tried the following (can you see what I wanted to do?):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/"> <!-- root of XML document -->
  <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
    <wml>

      <template>
        <do type="prev" label="Back">
          <prev/>
        </do>
      </template>

      <xsl:for-each select="card">
        <card>
          <xsl:attribute name="id">
            <xsl:value-of select="cardid"/>
          </xsl:attribute>
          <xsl:attribute name="title">
            <xsl:value-of select="cardtitle"/>
          </xsl:attribute>

          <xsl:template match="img">
            <p>
              <xsl:attribute name="align">
                <xsl:value-of select="imgalign"/>
              </xsl:attribute>
              <img>
                <xsl:attribute name="src">
                  <xsl:value-of select="imgsrc"/>
                </xsl:attribute>
                <xsl:attribute name="alt">
                  <xsl:value-of select="imgalt"/>
                </xsl:attribute>
              </img>
            </p>
          </xsl:template>

          <xsl:template match="link">
            <p>
              <xsl:attribute name="align">
                <xsl:value-of select="linkalign"/>
              </xsl:attribute>
              <a>
                <xsl:attribute name="href">
                  <xsl:value-of select="linkhref"/>
                </xsl:attribute>
                <xsl:value-of select="linktitle"/>
              </a>
            </p>
          </xsl:template>

          <xsl:template match="text">
            <p>
              <xsl:attribute name="align">
                <xsl:value-of select="textalign"/>
              </xsl:attribute>
              <xsl:value-of select="value"/>
            </p>
          </xsl:template>

        </card>
      </xsl:for-each>
    </wml>
  </xsl:template>
</xsl:stylesheet>

-----Original Message-----
From: owner-xsl-list@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Linda van den Brink
Sent: 10. august 2000 13:36
To: 'xsl-list@mulberrytech.com'
Subject: RE: How dynamic is XSL?


I assume that you want your output to be an equally arbitrary mix?

Then that's easy to accomplish with xsl:template and xsl:apply-templates.
Just write a template for each of your elements, and these template rules
will fire whenever an element is found in the input document.

If you would use xsl:for-each, then as you say if the xsl:for-each selects
links, these would be processed first, and then if you have a second
xsl:for-each select="text", the text would be processed next. xsl:for-each
involves building up the resutl and 'pulling' data from the source file,
while xsl:template/apply-templates involves reading the source XML and
'pushing' data to the result.

I don't have a sample of your source so I'm leaving it at this rather
abstract explanation.

Linda


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]