[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Find node-set from string
Subject: [xsl] Find node-set from string From: "Per Osnes" <per.osnes@xxxxxx> Date: Wed, 29 Nov 2006 13:21:53 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] template matching using n, Michael Kay | Thread | Re: [xsl] Find node-set from string, Florent Georges |
Re: [xsl] invoking nodes from multi, Florent Georges | Date | [xsl] XHTML Link stripping, Peter Hollas |
Month |
Keywords