conditionally output cdata?

Monday, 24 October 2011 · 3 messages · last reply 25 Oct 2011
KC
Kevin S. Clarke24 Oct 2011 23:28 #
Hi, I'm trying to conditionally output CDATA, but don't seem to be finding the right syntax for it. This works:
  declare option output:cdata-section-elements "div";

  <div><![CDATA['<div/>']]></div>
But this doesn't:
  declare option output:cdata-section-elements "div";

  <div>{
    if (1 = 2) then '' else <![CDATA['<div/>']]>
  }</div>
Any hints on how to do this? Thanks! Kevin
KC
Kevin S. Clarke25 Oct 2011 01:16 #
Answering my own question... :-)
  declare option output:cdata-section-elements "div";

  <div>{
    if (1 = 2) then '' else '<div/>'
  }</div>
I was misinterpreting what cdata-section-elements means... it puts everything in that element in CDATA for you (so it will supply the <![CDATA[ ]]>). Interesting, this works okay in the lastest BaseX editor, but in OxygenXML (using the BaseX data source) this doesn't work. Does the XQJ connection not allow the declaring of options? Thanks, Kevin
Quoted text · Kevin S. Clarke · 25 lines
On Mon, Oct 24, 2011 at 3:28 PM, Kevin S. Clarke <ksclarke at gmail.com> wrote: > Hi, > > I'm trying to conditionally output CDATA, but don't seem to be finding > the right syntax for it. > > This works: > > declare option output:cdata-section-elements "div"; > > <div><![CDATA['<div/>']]></div> > > But this doesn't: > > declare option output:cdata-section-elements "div"; > > <div>{ > if (1 = 2) then '' else <![CDATA['<div/>']]> > }</div> > > Any hints on how to do this? > > Thanks! > Kevin >
CG
Christian Grün25 Oct 2011 13:31 #
Hi Kevin,
Quoted text · Kevin S. Clarke · 3 lines
> Interesting, this works okay in the lastest BaseX editor, but in > OxygenXML (using the BaseX data source) this doesn't work. Does the > XQJ connection not allow the declaring of options?
Yes, I could reproduce this behavior; I guess that the result is reinterpreted by the editor. Might be interesting to direct this to the oXygen mailing list as well.. Christian

⚡Generated with XQuery