From: Chris Bayes (chris@bayes.co.uk)
Date: Fri Dec 07 2001 - 02:29:27 CET
Just some ideas about what I found out implementing this. It is msxml
specific but it does provoke a couple of ideas. I could create the
database in memory without a problem by having a meta-document and
applying the following stylesheet
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tq="http://www.xmlportfolio.com/transquery"
>
<xsl:output method="xml" />
<xsl:template match="/">
<tq:tq>
<xsl:copy-of select="document(//file/@href)" />
</tq:tq>
</xsl:template>
</xsl:stylesheet>
To the output from dirtoxml. i.e.
<folder>
<folder>
<file href="d:\transquery\db\1.xml />
</folder>
<file href="d:\transquery\db\a.xml />
</folder>
Then I could pass the tq:input param as
var tem = new ActiveXObject("MSXML2.XSLTemplate");
tem.stylesheet = XSL;
var proc = tem.createProcessor();
var transquery = godbfXML.selectSingleNode("/tq:tq");
proc.addParameter("database", transquery, "http://www.xmlportfolio.com/transquery"); ...
Ok that works because you have a root node tq:tq all is fine. I guess
that I am not precluded from doing that? Now to fit in with the spec(?)
I need to provide a node-set as the tq:input param. So one would think
that
var tem = new ActiveXObject("MSXML2.XSLTemplate");
tem.stylesheet = XSL;
var proc = tem.createProcessor();
var transquery = godbfXML.selectNodes("/tq:tq/*");
proc.addParameter("database", transquery, "http://www.xmlportfolio.com/transquery");
would work but it doesn't. Maybe I got something wrong but it seems that
a node-list when passed in from the outside as an object doesn't work as
a node-set. I solved it in transquery.js but then it occurred to me why
not have a root element <tq:tq ? I don't think that it would add much to
the spec and it could carry a bunch of attributes that might be useful.
For a moment I thought that it might add a bit of error checking but
soon dismissed that. Then it occurred to me that the output from
dirtoxml might also be useful. You could implement a simple text search
over the database and find the file the text was found in. i.e.
<xsl:template match="/tq:tq">
<xsl:apply-templates
select="$tq:input//something[text()=$searchString]" />
</xsl:template>
<xsl:template match="something">
Text String <xsl:value-of select="$searchString" /> Found In
File <xsl:value-of select="ancestor::*[@href][1]/href" />
</xsl:template>
Ok it would work differently if all of the data came from a database but
I'm sure there are things you could put into the folder/file elements
that would be useful from a db point of view. Also wanting to avoid
feature bloat I don't want to advocate much more than the simple param
passing mechanism but what about a small simple schema describing the
structure of the input database. Maybe it is too much I don't know maybe
it should describe branches and leaves or tables and columns instead of
folders and files. I still don't know but if you would like a
folder/file version to play with I could let you have a copy.
Ciao Chris
XML/XSL Portal
http://www.bayes.co.uk/xml
This archive was generated by hypermail 2.1.4 : Fri Feb 22 2002 - 11:35:58 CET