[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

merging with document()

Subject: merging with document()
From: "Jeff Shevlen" <jeff@xxxxxxxxxxxxxx>
Date: Wed, 18 Sep 2002 21:12:04 -0700
merging a document
Hi,

I want to merge, and otherwise compare and manipulate, multiple xml
docs in one stylesheet.  I've met with some success, but I'm having a
lot of trouble too.  I have couple of questions:

1. A general question about approach and best practice.  I've played
with 2 methods of reading in the files:

    (1) reading the files into variables - nodesets - and working with
the nodesets
  <xslt:variable name="file01" select="string(m:file01)" />
  <xslt:variable name="file02" select="string(m:file02)" />
  <xslt:variable name="file03" select="string(m:file03)" />
    [ ... ]
  <xslt:param name="nodes01" select="document($file01,/*)/node()" />
  <xslt:param name="nodes02" select="document($file02,/*)/node()" />
  <xslt:param name="nodes03" select="document($file03,/*)/node()" />

    (2) letting the templates sort it all out using apply-templates
   <xslt:apply-templates select = "document($file01)" />
    [ ... ]
    <xslt:template match = "//element03">
    [ ... ]

With regards to (1) I've found it awkward to navigate the nodesets to
access the elements and attributes I want to test.  I've been looking
at a merge stylesheet found at
http://www.informatik.hu-berlin.de/~obecker/XSLT/ - and it's been
great - but he uses recursion to loop through the different nodesets,
and I was wondering if there was a simpler way to do it.

Using the (2)nd approach seemed more straight forward to me -
initially - but I ran into problems passing params around and trying
to match similarly named elements in different source docs (see next
question).

  2. How do you use namespace prefixes to in match expressions
properly.  The following doesn't work and I assume it's something
simple, but what I don't know.

<xslt:stylesheet version = "1.0"
 xmlns:xslt = "http://www.w3.org/1999/XSL/Transform"
 xmlns:m = "http://abc.com/xml/transforms/merge"
 xmlns:o = "http://abc.com/xml/overview"
 xmlns:r = "http://abc.com/xml/roles">

 <xslt:template match = "m:merge">
  <xslt:variable name="file01" select="string(m:file01)" />
  <xslt:variable name="file02" select="string(m:file02)" />
  <xslt:variable name="file03" select="string(m:file03)" />

  <xslt:param name="o-nodes" select="document($file01,/*)/node()" />
  <xslt:param name="r-nodes" select="document($file02,/*)/node()" />
  <xslt:param name="s-nodes" select="document($file03,/*)/node()" />

  <xslt:element name = "newdoc">
    <xslt:attribute name = "newdoc_ID">
    <xslt:value-of select = "newdoc_01'"/>
   </xslt:attribute>
   <xslt:apply-templates select = "document($file01)" />
  </xslt:element>
 </xslt:template>

 <xslt:template match = "//o:overview">
  <xslt:message >
   <xslt:text />overview id = <xslt:value-of select = "@o:overviewID"
/>
  </xslt:message>
 </xslt:template>

</xslt:stylesheet>

When I remove the "o:" prefixes things work just fine.
=================================

TIA,
Jeff





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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.