[MarkLogic Dev General] Any easy way to set xml version and encoding?

Kari Cowan KCowan at alm.com
Thu Feb 2 11:25:38 PST 2017


Perfect, thanks – that did the trick.  I knew there must be some simple solution -- I was overthinking it.



From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of William Sawyer
Sent: Thursday, February 02, 2017 11:06 AM
To: MarkLogic Developer Discussion <general at developer.marklogic.com>
Subject: Re: [MarkLogic Dev General] Any easy way to set xml version and encoding?

It should work if you make it a string literal.
let $rss:= (
  '<?xml version="1.0" encoding="UTF-8"?>',
  <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sailthru="http://www.sailthru.com/rss-extension">
    <channel>
      <title>Some Title</title>
      <description>Some Description</description>
      <atom:link href="URL" rel="self" type="application/rss+xml" />
      STUFF
    </channel>
  </rss>
)

return (
  $rss
)

On Thu, Feb 2, 2017 at 11:47 AM, Christopher Hamlin <cbhamlin at gmail.com<mailto:cbhamlin at gmail.com>> wrote:
There's some info on controlling serialization here:  https://help.marklogic.com/knowledgebase/article/View/328/0/xml-serialization-and-output-options

/ch

On Thu, Feb 2, 2017 at 1:45 PM, Kari Cowan <KCowan at alm.com<mailto:KCowan at alm.com>> wrote:
I have a query the returns an RSS output implementation with some custom nodes.

I need to insert <?xml version="1.0" encoding="UTF-8"?> ahead of the <rss version..> declaration.

I found this article from 2009 but wanted to check if there was another way or newer simpler approach I could do directly in the xQuery.  Any ideas?
http://markmail.org/message/kwu24lbcdrt2dcim


let $rss:=
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sailthru="http://www.sailthru.com/rss-extension">
  <channel>
    <title>{$title}</title>
    <description>{$desc}</description>
    <atom:link href="{$link}" rel="self" type="application/rss+xml" />
                {$output}
</channel></rss>

Returns:
[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Version_
67.
68. let $rss:=
69. <?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sailthru="http://www.sailthru.com/rss-extension">

_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20170202/d9806763/attachment.html 


More information about the General mailing list