Using extension functions to query data files

Subject: Using extension functions to query data files
From: Peregrine.Stone@xxxxxxxx
Date: Tue, 6 Jul 2004 15:45:32 +0100
I am using Xalan C++ v1.5 on OpenVMS and am  trying to create extension 
functions that will return data from an RMS file (no SQL available).
This works fine and I can read all the data I want one record at a time; 
however I have a problem trying return a results list from a search.

The following is basically what i am doing now

XSL
<xsl:template match="query"/> 
 <query>
     <key><xsl:value-of select="@data-item"/></key>
     <data><xsl:value-of 
select="external:get_data(@key,@data-item)"/></data>
  </query>
</xsl:template>

XML-in
<xml>
 <query match="12-34" data-item="A"> 
 <query match="12-567" data-item="A">
 <query match="12-897" data-item="A">
 <query match="12-345" data-item="A">
</xml>

XML-out
<query> 
 <key>12-34</key>
 <data>XYZ</data>
</query>

The disadvantage with this method is that the XML must contain all the 
keys for the records I require.

The following code fragments should indicate what I am trying to do

XSL
<xsl:template match="query"/>
  <xsl:for-each select="external:do_query(@match,@data-item)"/>
    <query>
     <key><xsl:value-of select="@current-key"/></key>
     <data><xsl:value-of select="@current-data)"/></data>
     </query>
  </xsl:for-each>
</xsl:template>

XML-in
<xml>
  <query key="12-*" data-item="A"> 
</xml>

XML-out
<query> 
 <key>12-34</key>
 <data>XYZ</data>
</query>

The XML contains only the a query statement. This implies that do_query 
can modify the (nodeset) source xml to add the following node(s)
<current current-key="12-34" current-data="XYZ"/>


Is this possible, or is there a better way? Xalan does not seem to allow 
the addition of nodes to a nodeset within an extension function.

The following (test code [derived from Saxon range]) returns an error when 
run

                               XalanDOMString ws("12-34");
 XPathExecutionContext::BorrowReturnMutableNodeRefList 
result(executionContext);
                               XalanText* wNode = 
context->getOwnerDocument()->createTextNode(ws);
 result->addNode(static_cast<XalanNode*>(wNode));

                             return 
executionContext.getXObjectFactory().createNodeSet(result);


The alternative of course is that I try an implement a loop for all seach 
matches in the xslt with appropriate extension functions that use 
createString() and return single nodes only.


-----------------------------------------
The information in this e-mail is confidential. It is intended solely for the addressee. If you are not the intended recipient please notify the sender immediately and delete this message. Any review, dissemination, distribution, copying or other use of this communication or the information in it is strictly prohibited.


Current Thread