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>
|