Prefixed name tests : namespace « XQuery « XML






Prefixed name tests


File: Data.xml


<prod:car xmlns:prod="http://java2s.com/prod">
  <prod:id>0002</prod:id>
  <prod:name language="en">name 2</prod:name>
</prod:car>

File: Query.xquery

declare namespace prod = "http://java2s.com/prod";
<prod:prodList>{
  doc("Data.xml")/prod:car/prod:id
}</prod:prodList>


Output:

<?xml version="1.0" encoding="UTF-8"?>
<prod:prodList xmlns:prod="http://java2s.com/prod">
   <prod:id>0002</prod:id>
</prod:prodList>

 








Related examples in the same category

1.Querying with namespaces
2.Using a namespace declaration in a constructor
3.Namespace declarations in query different from input document
4.Using namespace declaration attributes
5.Namespace declaration impact on input elements
6.Using XML namespace declarations
7.Prolog namespace declarations