Useful-function: max-string : max « XQuery « XML






Useful-function: max-string


File: Data.xml
<inventory id="inv0001" date="2008-12-19" loc="USA">
  <car model="A" id="0001" quantity="1" color="navy"/>
  <car model="B" id="0002" quantity="1" color="red"/>
  <car model="B" id="0003" quantity="2" color="red"/>
  <car model="C" id="0004" quantity="1" color="white"/>
  <car model="C" id="0004" quantity="1" color="gray"/>
  <car model="A" id="0001" quantity="1" color="black"/>
</inventory>



File: Query.xquery

declare namespace functx = "http://www.java2s.com";
declare function functx:max-string ($stringSeq as xs:string*) as xs:string?{
   max($stringSeq)
};

(: function call :)
functx:max-string(doc("Data.xml")//car/@model)


Output:

<?xml version="1.0" encoding="UTF-8"?>C

 








Related examples in the same category