xsl-list
[Top] [All Lists]

Re: Re: Move (ascend) an element

2004-11-09 15:34:20
Hi Naomi,

At 04:27 PM 11/9/2004, you wrote:
I used a modification of the provided example to try
and move indexterms from inside /figure/title to just
above the title, but I seem to be losing my figure
attributes like id and role (because of a shallow
copy?)--doing it this way also for some reason takes
another indexterm from earlier in the xml file and
puts it right before the one I want moved (this, I
have no clue about):

<xsl:template
match="figure[child::title[child::indexterm]]">
   <xsl:copy>
     <xsl:copy-of select="//indexterm"/>

"//indexterm" translates to "/descendant-or-self::node()/child::indexterm", meaning all indexterms in the document, which is why you get them.

You want ".//indexterm", which collects all the indexterms inside the context node.

Not a big deal, but the conventional way to write your match expressions would probably be

match="figure[./title/indexterm]"

(short for child::figure[self::node()/child::title/child::indexterm])

and

match="figure/title/indexterm"

(instead of match="indexterm[parent::title[parent::figure]]")

They work the same as yours but are a bit easier to read for the XPath-fluent.

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
======================================================================



<Prev in Thread] Current Thread [Next in Thread>