At 2009-10-22 13:25 -0400, Helen Chen wrote:
I need to check if a node is a type of element, and this element has
namespace, the value for namespace and local name are all stored in
variable, or at least the local name is in variable,

Fine.

when I tried to
use it in typwswitch, it seems that in case part the element does not
like variable,

Indeed it should not ... element() is a node test it is not a function call:

  http://www.w3.org/TR/2007/REC-xquery-20070123/#doc-xquery-ElementTest

How can I do it?

By using node-name() as shown below.

I hope this helps.

. . . . . . . . . Ken

T:\ftemp>type helen.xq
let $subname := "subsect1"
let $testsubnode := element { fn:QName("http://www.somens.com";,
$subname) }
          {  "test node" }
return
if ( node-name($testsubnode) = fn:QName("http://www.somens.com";, $subname) )
       then "found" else "not found"

T:\ftemp>xquery helen.xq
<?xml version="1.0" encoding="UTF-8"?>found
T:\ftemp>


--
Upcoming:  hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009
Interested in other classes?  http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:[email protected]
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to