Hi all,

I am using xalan-c 1.8.0 for the generation of an XML file using another XML
file and an XSLT file as input.

For a special spatial functionality I have to call an external function with
2 parameters.

The external function expects 2 strings containing the stringrepresentaion
of two elements of my input source.

input:
<?xml...>
<Main>
...
 <Foo>
  <SubFoo>
   <Value>
    blah
   </Value>
  </SubFoo>
 <Foo>
 <Bar>
  <SubFoo>
   <Value>
    blahblah
   </Value>
  </SubBar>
 <Bar>
...
</Main>

xls:
...
 <xsl:template match="/">
 ...
  <xsl:variable name="foo" select="//Foo[1]"/>
  <xsl:variable name="bar" select="//Bar[1]"/>
  <xsl:variable name="result"
select="ext:compare($foo/SubFoo,$bar/SubFoo)"/>
 ...


The excecute-method of my external function class looks like:
XObjectPtr FunctionCompare::execute(XPathExecutionContext& executionContext,
XalanNode* context,
            const XObjectPtr arg1, const XObjectPtr arg2,
            const LocatorType* locator) const
{
#if defined(XALAN_STRICT_ANSI_HEADERS)
 using std::strlen;
#endif

 if (arg1.null() || arg2.null())
 {
  executionContext.error(getError(), context, locator);
 }

 bool intersectsResult;

 std::vector<char> geom1CharVek = arg1->str().transcode();
 char* geom1Chars = &geom1CharVek[0];

 std::vector<char> geom2CharVek = arg2->str().transcode();
 char* geom2Chars = &geom2CharVek[0];

// debug
 std::cerr << "geom1Chars " << geom1Chars << std::endl;
 std::cerr << "geom2Chars " << geom2Chars << std::endl;
// debug

// todo...
 comparisonResult = true;
// todo...

 return
executionContext.getXObjectFactory().createBoolean(comparisonResult);
}


Actually the two "Value"s themselves are complex GML structures.
Inside of the external function I need the parameters as strings like
------------------------------
   <Value>
    blah
   </Value>
------------------------------
... and ...
------------------------------
   <Value>
    blahblah
   </Value>
------------------------------
... but I do get them like ...
------------------------------

    blah

------------------------------
... and ...
------------------------------

    blahblah

------------------------------

The result (true/false) is returned correctly.

What am I doing wrong?

Thanks, Ulf

Reply via email to