[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Qexo-general] Why isn't this working? Is it a bug?
From: |
Craig Munday |
Subject: |
RE: [Qexo-general] Why isn't this working? Is it a bug? |
Date: |
Wed, 23 Jul 2003 12:52:18 +1000 |
Hi,
I was just wondering whether anyone could help me with the problem I've
outlined below. I'm not sure whether the behaviour I'm seeing is expected
behaviour or is a bug. If it is a bug, would anyone have a work around or
fix for it?
Regards,
Craig.
-----Original Message-----
From: Craig Munday [mailto:address@hidden
Sent: Friday, 18 July 2003 11:59 AM
To: address@hidden
Subject: [Qexo-general] Why isn't this working? Is it a bug?
Hi,
I'm having a problem with a recursive query that I hope someone can help me
with.
Here are the details:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-
The XML file:
<?xml version='1.0' encoding='UTF-8' ?>
<level1>
<element1>some data</element1>
<element1>some data</element1>
<level2>
<element1>some data</element1>
<element1>some data</element1>
</level2>
</level1>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-
The Generated Output:
I'm expecting <wrong-count> to be 3, that is, the count of level2/element1
and level2/additional-level, instead it only appears to count
<additional-level> and not <element1>. If I remove the generation of the
<additional-level> tag then the count become zero.
<level1>
<element1>some data</element1>
<element1>some data</element1>
<level2>
<element1>some data</element1>
<element1>some data</element1>
<additional-level>
</additional-level>
</level2>
<correct-count>3</correct-count>
<wrong-count>1</wrong-count>
</level1>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-
The XQL file:
declare namespace properties-util =
"class:ecard.cardtrack.tasks.xquery.KawaQexoPropertiesUtil"
define function dealWithLevel2( $level2 )
{
<level2>
{ for $element in $level2/* return validateTree( $element ) }
<additional-level>
</additional-level>
</level2>
}
define function dealWithLevel1( $level1 )
{
let $children := for $element in $level1/* return validateTree( $element
)
return
(
<level1>
{ $children }
{ element correct-count { count($children) } }
{ element wrong-count { count( $children/* ) } }
</level1>
)
}
define function validateTree( $n as node() )
{
typeswitch( $n )
case element level1
return dealWithLevel1( $n )
case element level2
return dealWithLevel2( $n )
default
return $n
}
{--
Main loop
--}
let $docName := properties-util:getInputFileName(),
$document := document( $docName )
return document { dealWithLevel1( $document/level1 ) }
Cheers,
Craig.
_______________________________________________
Qexo-general mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/qexo-general