[xslt] xmlNodeSetBase Question



I am working on a C app using libxslt.

I am needing some guidance with using xmlSetNodeBase....

I have three very simple xsl files to illustrate my problem....

---->parent.xsl<----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:import href="xsl/child.xsl" />
<xsl:template match="/">
    I'm the Parent!!! <BR />
    <xsl:call-template name="child" />
</xsl:template>
</xsl:stylesheet>

--->child.xsl<---
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:import href="xsl/grandchild.xsl" />
<xsl:template name="child">
    I'm the Child!!! <BR />
    <xsl:call-template name="grandchild" />
</xsl:template>
</xsl:stylesheet>

--->grandchild.xsl<---
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template name="grandchild">
    I'm the Grandchild <BR />
</xsl:template>
</xsl:stylesheet>


If I remove the referneces in child.xsl to the grandchild tempalte the  
transformation runs smoothly I get desired result... When I add the  
references to grandchild.xsl into the child I receive the following  
error.

xsl:import : unable to load file:///www/htdocs/xsl/xsl/grandchild.xsl

Segment of C APP

For this example importbase is equivalent to the string  
file:///www/htdocs/

...
     
xmlSetGenericErrorFunc(xmlGenericErrorContext,(xmlGenericErrorFunc)xmler 
ror);
      
xsltSetGenericErrorFunc(xmlGenericErrorContext,(xmlGenericErrorFunc)xmle 
rror);
     errtype[0]='\0';
     strcat(errtype,"xml parse - ");

     xml = xmlParseMemory((*xmlstring)->value.str.val,
                           (*xmlstring)->value.str.len);

     xmlNodeSetBase(xml,importbase);
     if (errorfound) {
        RETURN_FALSE;
        return;
     }

     xsl = xmlParseMemory((*xslstring)->value.str.val,
                          (*xslstring)->value.str.len);

     xmlNodeSetBase(xsl,importbase);
     if (errorfound) {
         RETURN_FALSE;
         return;
     }

     style = xsltParseStylesheetDoc(xsl);
     xmlNodeSetBase(style->doc,importbase);

     //Error Occurs at this point....
     res = xsltApplyStylesheet(style, xml, params);
...

The desired effect I am looking for the grandchild to resolve out to  
file:///www/htdocs/xsl/grandchild.xsl instead of this  
file:///www/htdocs/xsl/xsl/grandchild.xsl....
basically I guess I do not want to inherit the directory level from the  
child I want to inherit straight from the xmlNodeSetBase....

The choice of setting an absolute path on everything or the choice of  
just moving the grandchild.xsl to truely be relative to the child is  
not practical. I have a substantial code base built around another xslt  
engine which I am trying to migrate away from due to performance issues.

Any help is greatly appreciated....

THanks

	Shane










[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]