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

Re: More XSL Discussion


Subject: Re: More XSL Discussion
From: Norman Walsh <norm@xxxxxxxxxxxxx>
Date: Tue, 24 Feb 1998 14:05:55 -0500

/ "Michael Kay" <M.H.Kay@xxxxxxxxxxxxx> was heard to say:
[...]
| I can't think of a <UL> example off my head, but the following example is
| real. The XML is:
| 
| <SPEECH>
| <SPEAKER>ROSENCRANTZ</SPEAKER>
| <SPEAKER>GUILDENSTERN</SPEAKER>
| <LINE>The single and peculiar life is bound,</LINE>
| <LINE>With all the strength and armour of the mind.</LINE>
| <STAGEDIR>Exeunt</STAGEDIR>
| </SPEECH>
| 
| and I want to render it in HTML as
| 
| <TABLE><TR>
| <TD>ROSENCRANTZ<BR>GUILDENSTERN</TD>
| <TD>The single and peculiar life is bound<BR>
| With all the strength and armour of the mind.<BR>
| <I>Exeunt</I></TD>
| </TR></TABLE>
| 
| how do I do that in XSL? I can do it easily, of course, by generating
| unbalanced tags in CDATA, but I'm told that's cheating.

It is.  Here's another way.  (Note: I did this from memory,
without consulting the XSL proposal, so it may not be
syntactically perfect...)

<rule>
  <target-element type="SPEECH">
  <TABLE>
  <TR><TD>
     <select-elements mode="speakers">
       <target-element type="SPEAKER"/>
     </select-elements>
  </TD><TD>
     <select-elements mode="lines">
       <target-element type="LINE"/>
     </select-elements>
     <select-elements mode="lines">
       <target-element type="STAGEDIR"/>
     </select-elements>
  </TD></TR>
  </TABLE>
</rule>

<rule mode="speakers"
  <target-element type="SPEAKER" position="first-of-type"/>
  <children/>
</rule>

<rule mode="speakers"
  <target-element type="SPEAKER">
  <BR/><children/>
</rule>

<rule mode="lines"
  <target-element type="LINE">
  <children/><BR/>
</rule>

<rule mode="lines"
  <target-element type="STAGEDIR">
  <I><children/></I>
</rule>

I'm not going to argue that that is particularly pretty.  In
DSSSL, I'd probably do it by building the node-lists for
speakers, lines, and stage directions explicitly and then
processing those lists.  But we haven't got that kind of
functionality defined in the XSL scripting language yet.

                                        Cheers,
                                          norm
-- 
Norman Walsh <nwalsh@xxxxxxxxxxxxx> | The First Amendment is often
Senior Application Analyst          | inconvenient. But that is besides
ArborText, Inc. (www.arbortext.com) | the point. Inconvenience does not
413.549.3868 Voice/FAX              | absolve the government of its
                                    | obligation to tolerate
                                    | speech.--Justice Anthony Kennedy,
                                    | in 91-155


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



Current Thread
Keywords