[xquery-talk] Adding xml header to xquery result

Michael Kay mhk at mhk.me.uk
Fri May 13 21:42:59 PDT 2005

The XML declaration isn't part of the data model, therefore it can't be
created by the query. Creating it is the job of the serializer.
Serialization varies from one processor to another, so the way you persuade
your product to output the XML declaration depends on the product. In Saxon,
add !omit-xml-declaration=no to the command line (oddly XQuery has decided
that omitting the XML declaration should be the default).

Michael Kay

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of McAuley, Grant (LLU)
> Sent: 13 May 2005 20:29
> To: talk at xquery.com
> Subject: [xquery-talk] Adding xml header to xquery result
> I want to create an xml document as a result of an xquery and 
> I need to
> add
> '<?xml version="1.0"?>' at the top of the file.  The few 
> Xquery engines
> I have tried complain if I add this to the xquery file.
> I.e.:
> 	<?xml version="1.0'?>
> 	{
> 	for $x in doc('test.xml')//test
> 	where $x/@status = 'approved'
> 	order by $x/@f-id
> 	return
> 	<request>
> 		<name>{ concat($x/first,' ',$x/last) }</name>
> 	</request>
> 	}
> doesn't work b/c of the header.
> I want to see this output:
> 	<?xml version="1.0'?>
> 	<request>
> 		<name>Joe Smith</name>
> 	</request>
> Is there a standard way to do this?
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk

More information about the talk mailing list