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

Find node-set from string

Subject: Find node-set from string
From: "Per Osnes" <per.osnes@xxxxxx>
Date: Wed, 29 Nov 2006 13:21:53 +0100
xquery node set from string
Hi all,
I have looked into som old discussions regarding need for a string to
node-set conversion (but miss the conclusions?). As far I can see the
exslt:node-set does not support this (i.e. in Saxon 8B), but maybe I
misinterpret "You can also use this function to turn a string into a text
node, which is helpful if you want to pass a string to a function that only
accepts a node-set."
(http://www.exslt.org/exsl/functions/node-set/index.html). 
In addition the "function-available" returns false for saxon:evaluate
(saxon.sf.net) and dyn:evaluate (exslt.org/dynamic).

Q1: Is there any other alternatives for such a conversion?


(If no:)
My purpose is to convert between different XSD/XML formats by means of a
mapping file generated from a database (i.e. a reference data library),
hence the data from the input file shall be transformed to corresponding
elements in the output file according to defined criterias. The mapping file
itself can be constructed as needed from the db output.
So far it seems to be easiest to store the "full path" (A/B/C) of the data
elements in db, and map between them like:
  <mappings>
    <map>
      <format_1>message/header/from</format_1>
      <format_2>notification/originator</format_2>
    </map>
    ...
  </mappings>
(An alternative for the mapping file can be utilising id's from the db - as
I have a working solution for this. But these id's may change at updates and
therefore I'm looking into other possibilities.)

In my XSLT (2.0) I will
a) parse the to-file (XSD, format_2) to find the next possible output
element
b) search the mapping file for this entry
c) read data from the corresponding element in the input file (XML,
format_1)
d) output to-element with from-contents.

My concern is point c. From the example above, I want to search file1 for
element message/header/from. One solution is to convert the found text to a
sequence and search the input file e.g. by 
  /*[name()=$seq[1]]/*[name()=$seq[2]]/*[name()=$seq[3]]...
A complicating factor here might be the variable structure length, but I'm
sure it's solveable.
An alternative could be to add a path-attribute to all elements in the input
file, but this seems to be redundant and not very elegant:
  <message>
    <header>
      <from path="message/header/from">...

Q2: Are there better strategies / methods for solving this kind of problem?
(Not limited to what's sketched above.)


- Per Osnes -

(Sorry if the used terminology is not accurate.)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.