[MarkLogic Dev General] typeswitch with computed element name
Helen Chen
HCHEN at aip.org
Thu Oct 22 13:05:21 PDT 2009
Hi Ken,
It helps a lot. Thanks.
Helen
On Oct 22, 2009, at 1:39 PM, G. Ken Holman wrote:
> 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:gkholman at CraneSoftwrights.com
> Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/q/bc
> Legal business disclaimers: http://www.CraneSoftwrights.com/legal
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
More information about the General
mailing list