This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: efficient filtering of XML files. ( XML!=content && XSLT!=presentation )?
- To: xsl-list at mulberrytech dot com
- Subject: Re: efficient filtering of XML files. ( XML!=content && XSLT!=presentation )?
- From: Steve Tinney <stinney at sas dot upenn dot edu>
- Date: Wed, 05 Apr 2000 07:10:11 -0400
- References: <39B19660C174D311BB9000A0C9E01C3F18BA96@corfu.rnib.org.uk>
- Reply-To: xsl-list at mulberrytech dot com
"Pawson, David" wrote:
>
> Mike Brown
> <big snip/>
> >xsl:apply-templates can be very powerful when used to process, for
> >example, a source tree consisting of a purely structural
> >description of a
> >web site, and secondary source trees (retrieved via
> >document()) consisting
> >of presentational variables (colors, text styles, image names and
> >attributes) referenced by the structural tree.
>
> This made me think. My primary use of XSLT is producing multiple
> media from a single XML master document.
>
> One of the things I do is ask users not to put 'titles' into the source
> content, saying I can add this at transformation time.
>
> This means I prefix the contents of <attendees> with
> 'ATTENDEES: '
>
> I.e. I put content into the stylesheet. This also means I need to duplicate
> this for all media, which is potentially error prone due to typos.
>
> Mike, are you advocating something along the lines of a function
> which retrieves, from an external source, an appropriate 'styling' for
> the current node? Something like a function get-style(.) which returns,
> in your example, say, a colour, in mine, some heading text?
>
> For example, given a location such as minutes/rearmatter/attendees
> I am returned the string ATTENDEES.
>
> Then I could have all my 'fixed content' in a seperate file and make use
> of it in all appropriate media, perhaps even differentiating the media
> with a different parameter, so that I receive back 'formatted' strings
> appropriate to \tex, html, braille etc.
>
> Definately worth exploring. Thanks Mike.
>
> Regards, DaveP
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
I do something like this to format a <div> tag that takes its class as
@c, its number as @n and may be nested. In names.xml I have:
<names>
<div c="section">Section</div>
<div c="tablet">Tablet</div>
<div c="source">Source</div>
<div c="fragment">Fragment</div>
</names>
and then in the script:
<xsl:template match="div">
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="document('names.xml')/*/div[@c=current()/@c]">
<xsl:value-of
select="document('names.xml')/*/div[@c=current()/@c]"/>
</xsl:when>
<xsl:otherwise>
<xsl:message
terminate="no">composite: warning: unknown DIV class
'<xsl:value-of
select="@c"/>'</xsl:message>
<xsl:value-of select="@c"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="string-length(@n)>0">
<xsl:text> </xsl:text>
<xsl:value-of select="@n"/>
</xsl:if>
<xsl:if test="div"><xsl:text> </xsl:text></xsl:if>
</xsl:template>
Of course, I do this primarily because I want to avoid a lengthy
xsl:when to trap each possible class name, but the same principle could
be used to separate the content from the stylesheet.
Steve
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list