I have an xquery file that transforms from a.xml to b.xml. Below is an example of my x-query:
<TestMessage>
<Header>
<MessageType>
{for $x in doc("input.xml")//Test/NewHeader return
if ($x/MessageType/text() = "FIRST") then "FirstMessageType"
else "SecondMessageType"
}
</MessageType>
</Header>
</TestMessage>
This works fine and populates my MessageType properly. But I need to add a namespace as an attribute to the TestMessage element. So, when I do,
<TestMessage xmlns="http://www.testsource.com/TestMessage">
<Header>
<MessageType>
{for $x in doc("input.xml")//Test/NewHeader return
if ($x/MessageType/text() = "FIRST") then "FirstMessageType"
else "SecondMessageType"
}
</MessageType>
</Header>
</TestMessage>
The xquery result has an empty MessageType element. I haven't changed anything except add the namespace in the x-query document. But I don't understand why this gives me a wrong resultant xml.
Any help would be greatly appreciated.
thanks a lot!