Hi,

We encountered a strange problem with debug output from Orbeon Studio today.

In one of our pipelines we use an xsl stylesheet to construct an xquery for Tamino. We had a bug in this stylesheet where there were several unmatched text nodes that were making it into the result tree, and hence into the xquery. When the Tamino processor validated this query before sending to Tamino it would rightly throw the following exception:

org.orbeon.oxf.common.ValidationException: null, line -1, column -1 : Error character data is not allowed here(schema: http://www.orbeon.org/oxf/tamino-query) : null, line -1, column -1: Error character data is not allowed here(schema: http://www.orbeon.org/oxf/tamino-query)

When trying to debug this we added a debug attrib so we could see the xquery. However, the unmatched text nodes that were causing the problem did not appear in the logging event (or the console). Consequently, until we used the file serialiser to send the query to disk, we werent able to see any explanation for the validation exception.

The working query is as follows:
<?xml version="1.0" encoding="utf-8"?>
<xquery>
declare namespace xs="http://www.w3.org/2001/XMLSchema";
for $p in input()/pea, $h in input()/financialHierarchy//[EMAIL PROTECTED]/profitCenter/facilityID] where $h/ancestor = (25,456,1) return <pea-details>{$p/*}</pea-details>
</xquery>


without removing unmatched text nodes we get:

<?xml version="1.0" encoding="utf-8"?>mdrummondMike Drummond
"company"
department
concat(name, " ", string(count(preceding-sibling::*))) <xquery>
declare namespace xs="http://www.w3.org/2001/XMLSchema";
for $p in input()/pea, $h in input()/financialHierarchy//[EMAIL PROTECTED]/profitCenter/facilityID] where $h/ancestor = (25,456,1) return <pea-details>{$p/*}</pea-details>
</xquery>


Attached is the working version of pipeline in question, comment out line 54 to unleash the bug!

David Sinclair.
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline";
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:oxf="http://www.orbeon.com/oxf/processors";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";>

    <p:param type="input" name="instance" debug="INSTANCE IN"/>
    <p:param type="output" name="instance"/>

    <p:processor name="oxf:pipeline">
        <p:input name="config" href="oxf:/common-xpl/get-user-info.xpl"/>
        <p:output name="user" id="user"/>
    </p:processor>

    <p:processor name="oxf:tamino-query" 
xmlns:p="http://www.orbeon.com/oxf/pipeline";> 
        <p:input name="config" href="aggregate('config', 
/config/tamino.xml#xpointer(/config/*), /config/tamino-pea.xml)"/> 
        <p:input name="data"> 
            <xquery>   
            declare namespace xs="http://www.w3.org/2001/XMLSchema";         
            <planned> {
                for $pc in input()/plannedCapEx
                return
                 <pc-details>
                     {$pc/profitCenter,
                     <spend>{sum($pc/yearCapExSpend/monthCapExSpend[spendDate 
le xs:date("2004-09-01")]/spendValue)}</spend>} 
                 </pc-details>
            } </planned>
            </xquery>
        </p:input>
        <p:output name="data" id="plannedCapEx" />
    </p:processor>

    <p:processor name="oxf:xslt-2.0">
        <p:input name="data" href="aggregate('root', #user, #instance, 
/xml/peaSearchParams.xml)"/>
        <p:input name="config">           
            <xsl:stylesheet exclude-result-prefixes="f xs oxf p" version="2.0" 
                            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
                            xmlns:f="local-functions" 
                            xmlns:xs="http://www.w3.org/2001/XMLSchema";>        
    
                <xsl:template match="/root/queryParams">      
                    <xquery>
                        declare namespace xs="http://www.w3.org/2001/XMLSchema";
                        <xsl:text>for $p in input()/pea, $h in 
input()/financialHierarchy//[EMAIL PROTECTED]/profitCenter/facilityID] where 
$h/ancestor = (</xsl:text>
                        <xsl:value-of 
select="/root/doc('oxf:/xml/user.xml')//group" separator=","/>
                        <xsl:text>)</xsl:text>          
                        <xsl:apply-templates select="predicate" />
                        <xsl:text> return </xsl:text>                 
                        <pea-details>
                        <xsl:text>{$p/*}</xsl:text>                 
                        </pea-details>
                    </xquery>
                </xsl:template>
                
                <!-- Comment this out to break the query... -->
                <xsl:template match="text()" />
                
                <xsl:template match="predicate" />
                                
                <xsl:template match="predicate[every $x in param satisfies 
(/root/xform-instance/form/ui/search/*[name()=$x and . != ''])]">
                    <xsl:text> and (</xsl:text>
                    <xsl:value-of select="f:expand(., xpath, 1, 
/root/xform-instance/form/ui/search)" />
                    <xsl:text>)</xsl:text>      
                </xsl:template>               
                
                <xsl:function name="f:expand">
                    <xsl:param name="predicate"/>
                    <xsl:param name="skeletonXPath"/>
                    <xsl:param name="paramNumber" as="xs:integer"/>
                    <xsl:param name="form"/>
                    <xsl:variable name="paramValue" select="$form/*[name() = 
$predicate/param[$paramNumber]]"/>                                        
                    <xsl:variable name="regX" select="concat('%', 
string($paramNumber))"/>
                    <xsl:variable name="replacement" 
select="replace($skeletonXPath, $regX, $paramValue)"/>             
                    <xsl:choose>
                        <xsl:when test="contains($replacement, '%')">
                            <xsl:sequence select="f:expand($predicate, 
$replacement, $paramNumber+1, $form)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:sequence select="$replacement"/>
                        </xsl:otherwise>
                    </xsl:choose>                
                </xsl:function>
            </xsl:stylesheet>        
        </p:input>    
        <p:output name="data" id="xquery"/>
    </p:processor>

    <p:processor name="oxf:file-serializer" 
xmlns:p="http://www.orbeon.com/oxf/pipeline";>
        <p:input name="config">
            <config>
                <file>xquery.xml</file>
                <directory>c:/tmp</directory>
            </config>
        </p:input>
        <p:input name="data" href="#xquery"/>
    </p:processor>    
              
    <p:processor name="oxf:tamino-query" 
xmlns:p="http://www.orbeon.com/oxf/pipeline";> 
        <p:input name="config" href="aggregate('config', 
/config/tamino.xml#xpointer(/config/*), /config/tamino-pea.xml)" debug="CONFIG 
INPUT"/> 
        <p:input name="data"  href="#xquery" debug="XQUERY"/> 
        <p:output name="data" id="peas" debug="XQUERY RESULT"/>
    </p:processor>

        <!--
            <xquery>for $p in input()/pea return 
<pea-details>{$p/*}</pea-details></xquery>
        </p:input>-->                     
    <p:processor name="oxf:xslt-2.0">
        <p:input name="data" href="aggregate('result', 
#plannedCapEx#xpointer(/result/*), #peas#xpointer(/result/*))" debug="SOURCE 
DOC"/>
        <p:input name="groupingParams" 
href="#instance#xpointer(/form/ui/groupingParams)" />
        <p:input name="config">
            <xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
                <xsl:import href="oxf:/list/capitalForGenericGrouping4.xsl"/>   
             
                <xsl:param name="grouping-levels">
                    <xsl:copy-of 
select="doc('oxf:groupingParams')/*/*"></xsl:copy-of>
                </xsl:param>
            </xsl:stylesheet>
        </p:input>
        <p:output name="data" id="groupedPeas" debug="GROUPED-PEAS"/>
    </p:processor>
      
    <p:processor name="oxf:xslt-2.0">
        <p:input name="data" href="#instance"/>
        <p:input name="groupedPeas" href="#groupedPeas"/>
        <p:input name="config">
                        <xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
                                <xsl:import 
href="oxf:/oxf/xslt/utils/copy.xsl"/>
                                <xsl:template match="/form/documents">
                                        <xsl:copy>
                                                <xsl:copy-of 
select="doc('oxf:groupedPeas')/*"/>
                                        </xsl:copy>
                                </xsl:template>
                        </xsl:stylesheet>
        </p:input>
        <p:output name="data" ref="instance" debug="MODEL OUTPUT"/>
    </p:processor>

</p:config>

Reply via email to