xsl-list
[Top] [All Lists]

Re: [xsl] Output input_xml apart from one tag change?

2007-10-02 09:57:51
I like this last version with non-abbreviated xpath expression, it is
unambiguous for a beginner like me.

On 10/2/07, Wendell Piez <wapiez(_at_)mulberrytech(_dot_)com> wrote:
Scott,

At 11:50 AM 10/2/2007, you wrote:
Say you _don't_ know you want to copy them. I use it as a standard
identity template, because it allows me to do something like the
following afterward:

<xsl:template match="select[some condition]/@multiple"/>

Indeed: I thought I made that clear. My analysis wasn't intended to
recommend one method over the other in the general case, just to
clarify the tradeoffs, including the subtler ones that don't always
make a difference.

For whatever reason, we human beings are quick to make value
judgements where they're not necessary or useful. Something is not
necessarily bad because it's different, but since we're naturally
skittish about the unknown and about the risks that come with it, we
often can't help but feel that way when trying to deal with something
new. It's helpful when doing analysis to sort out all the options not
because we learn which approaches are good or bad, but why a given
approach may be good or bad in a given situation. Generalizing the
"good/bad" thing is just substituting allergies for judgements.

FWIW, the match="node()|@*" variant (your favorite) is the one that
appears in the XSLT spec. But experience shows it is rather
mysterious for people whose XPath is weak, and for those who don't
get the XSLT processing model. These are often the same people, which
is doubly frustrating for them. Separating apart these two aspects of
the problem often gives them a much easier way into seeing why the
solution works (and seeing much else along with it). Until then it's
just a magic spell at best.

One might also recommend

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

... which would have the opposite set of virtues (and vices).

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--