forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Noels" <stev...@outerthought.org>
Subject RE: import of xml.apache.org main site into forrest
Date Wed, 05 Jun 2002 14:49:11 GMT
Rob,

Have you tried XLink attribute processing with this approach?

How will you create a template now that will process 'any' attribute
that resides in a specific namespace? My advise is: use xsl:copy-of if
you know what you're doing. But be sure you really know what you're
doing ;-)

Consider this example:

test.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<book xmlns:bla="http://bla.org/ns/bla">
  <title bla:foo="test1" foo="test2">content</title>
</book>


test.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bla="http://bla.org/ns/bla">

  <xsl:template match="@bla:*">
    <xsl:attribute name="{name()}">this was an attribute in the bla
namespace, it's value being [<xsl:value-of select="."/>]</xsl:attribute>
  </xsl:template>

  <!-- <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template> -->

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

If you comment out my alternative of a copy-all without the use of
xsl:copy-of and remove comments from around yours, you'll see the
template for the bla namespaced attributes isn't triggered anymore.

That's bad practice, IMNSHO. Using xsl:copy-of limits the extensibility
of your stylesheet because ot bypasses the normal template matching
process.

</Steven>

> -----Original Message-----
> From: Robert Koberg [mailto:rob@koberg.com]
> Sent: woensdag 5 juni 2002 16:25
> To: forrest-dev@xml.apache.org
> Subject: Re: import of xml.apache.org main site into forrest
>
>
>
> ----- Original Message -----
> From: "Steven Noels" <stevenn@outerthought.org>
>
>
> > > From: Bert Van Kets [mailto:bert@vankets.com]
> >
> > > An alternative is
> > >
> > > <xsl:template match"/">
> > >    <xsl:copy-of>
> > >      <xsl:value-of select="."/>
> > >    </xsl:copy-of>
> > > </xsl:template>
> > >
> > > This copies the complete root node to the output incl.
> > > attributes and children.
> >
> > ... but doesn't allow you to specify any other templates
> for particular
> > patterns underneath the root node, since this template will
> bypass all
> > other templates that could affect the output tree. I teach
> this in my
> > courses as being a bad practice, do you guys have any
> thoughts on this?
> >
> > </Steven>
>
> Sure it does. Why is it a bad practice? This matches
> everything except what
> is specified:
>
> <xsl:template match="content">
>
>     <xsl:copy>
>         <xsl:copy-of select="@*"/>
>
>         <xsl:if test="@id=$folder_idref">
>             <art_xml label="{$label}" id="{$id}" lock="{$lock}"
> status="{$status}"/>
>         </xsl:if>
>
>         <xsl:apply-templates/>
>
>     </xsl:copy>
>
>
> </xsl:template>
>
> <xsl:template match="node()|@*">
>
>     <xsl:copy>
>         <xsl:copy-of select="@*"/>
>         <xsl:apply-templates/>
>     </xsl:copy>
>
> </xsl:template>


Mime
View raw message