Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5945345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:40:06+00:00 2026-05-22T16:40:06+00:00

I am trying to check if a node of namespace ‘X’ has a child

  • 0

I am trying to check if a node of namespace ‘X’ has a child node of a different namespace ‘Y’. I tried the following xquery:

declare namespace atom = "http://www.w3.org/2005/Atom";
declare namespace libx = "http://libx.org/xml/libx2";

let $doc := <node><entries xmlns="http://www.w3.org/2005/Atom" xmlns:libx="http://libx.org/xml/libx2"> 
             <libx:book-entry><book>Book 1</book><author>Author 1 PQR</author><title>Title 1</title></libx:book-entry> 
             <libx:car-entry><car>Car 1</car><model>Model 1</model><price>Price 1 PQR</price></libx:car-entry>
           </entries></node>, 
    $types := <types xmlns="http://libx.org/xml/libx2"><type>book-entry</type></types>, 
    $key := 'PQR'

for $type in $types/libx:type
return
   for $entry in $doc/atom:entries/*[name() eq $type]
     return $entry

I expect the result to be: <libx:book-entry><book>Book 1</book><author>Author 1 PQR</author><title>Title 1</title></libx:book-entry>. But, the query returns null as the name function does not take into account a different namespace. Is there another xquery function apart from name() which takes in a namespace parameter which would give the desired result.

Thanks,
Sony

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:40:07+00:00Added an answer on May 22, 2026 at 4:40 pm

    You could use the local-name() function to match just the elements’ local names (as you have listed them in $types).

    Or if you wanted to be really specific, a combination of the local-name() and namespace-uri() functions to match both element name and Namespace URI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to check a checkbox, i've tried doing the following :- $('#someId').attr('checked','checked'); $('#someId').attr('checked',
I'm trying to check if a certain node has a property footerTextTitle by: @foreach
I am trying to check the following and all throw an out of bounds
I am trying to check all the childnodes under a parent node, the code
I am trying to check whether a particular node exists or not like follows.
Could someone please check on codes. My XMLParser has caught an exception. I'm trying
I am trying to send a http request to a neo4j database using node.js.
I am trying to check at which node the cursor / selection is. I
I'm trying to set up a Hudson slave node. Following Hudson -- Step by
I am trying to check a series of buttons to see if they have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.