Placing sample XML in a Flare topic?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
MLimtiaco
Propeller Head
Posts: 12
Joined: Thu Jun 21, 2012 3:04 pm

Placing sample XML in a Flare topic?

Post by MLimtiaco »

Hello! I'm a Flare n00b (been using Flare for 2 weeks now) with a sample XML question. I'm working on an API document and need to place some sample XML in a topic. However, Flare seems to think that I'm trying to create a new XML document, and when I try to save the file I get this error message:

The file <filename> contains invalid XML:
Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 44, position 3.
Do you want to open it as text?

I've been using a pre.codeblock style for the sample C# and VB.NET code and it's been working fine (although seems like a kludge to this experienced RH user!). But it's not working for this sample XML. What do I need to do to make this happen?

Thanks to all in advance for any suggestions...

Matso Limtiaco
Everett WA USA
Rene Severens
Sr. Propeller Head
Posts: 210
Joined: Mon Sep 19, 2011 2:06 am
Location: Netherlands - Zoetermeer
Contact:

Re: Placing sample XML in a Flare topic?

Post by Rene Severens »

Hi,

Use this "feature":
Create a snippet that contains the XML.
Add the snippet to the TOC.
when the snippet is not used in a topic, but directly in the TOC it will render as XML.

Greetings,

Rene Severens.
"The numbers are strange today; they somehow do not seem to add up."
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Placing sample XML in a Flare topic?

Post by LTinker68 »

MLimtiaco wrote:Hello! I'm a Flare n00b (been using Flare for 2 weeks now) with a sample XML question. I'm working on an API document and need to place some sample XML in a topic.
I think if you place the XML code inside <pre> tags then it won't try to parse the code.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
MLimtiaco
Propeller Head
Posts: 12
Joined: Thu Jun 21, 2012 3:04 pm

Re: Placing sample XML in a Flare topic?

Post by MLimtiaco »

@ Lisa - Yup, the content is in a <pre.codeblock> section:

<pre xml:space="preserve" class="Codeblock">
<?xml version="1.0" encoding="UTF=8"?>
<CaptureInfo>
<Image Type="SigCap">
<FilePath>/My Documents/Sigcap.jpg </FilePath>
</Image>
<Barcode>
<STC_IDENTIFIER>xx</ STC_IDENTIFIER>
<Data>QUJDRA==</Data>
</Barcode>
</CaptureInfo></pre>

...and I'm still getting that error. Any ideas?
crdmerge
Sr. Propeller Head
Posts: 248
Joined: Tue Dec 16, 2008 5:37 am

Re: Placing sample XML in a Flare topic?

Post by crdmerge »

What if you remove the xml:space="preserve" from that pre tag?
MLimtiaco
Propeller Head
Posts: 12
Joined: Thu Jun 21, 2012 3:04 pm

Re: Placing sample XML in a Flare topic?

Post by MLimtiaco »

crdmerge wrote:What if you remove the xml:space="preserve" from that pre tag?
Nope - no effect.

I can see how creating a separate topic file for just this XML content could work, but it doesn't seem like you should have to leave the API topic page just to see a few sample lines of XML.
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Placing sample XML in a Flare topic?

Post by LTinker68 »

You shouldn't need to do this -- the <pre> tag should be doing it -- but you could try putting a CDATA tag around it. I don't think I've ever noticed a way to do it from within Flare's GUI (Flare puts it in itself sometimes), so you might have to open the topic in the Internal Text Editor and add it yourself.

More info on the CDATA tag is available at http://www.w3schools.com/xml/xml_cdata.asp.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
GinnyR
Propeller Head
Posts: 24
Joined: Mon Apr 27, 2009 5:07 pm

Re: Placing sample XML in a Flare topic?

Post by GinnyR »

You could take a screenshot of the text from notepad or even Flare's internal text editor and insert the xml as an image. I realize there should be a better way...
MLimtiaco
Propeller Head
Posts: 12
Joined: Thu Jun 21, 2012 3:04 pm

Re: Placing sample XML in a Flare topic?

Post by MLimtiaco »

Aha! Looks like wrapping the sample XML content in the CDATA tags does the trick.

For those who are following along at home: place "<![CDATA[" immediately after the opening <pre> tag, and place "]]>" immediately before the closing </pre> tag. Works for me and looks like this:

<pre class="Codeblock">
<![CDATA[<?xml version="1.0" encoding="UTF=8"?>
<MyXMLTag>
<MoreXML>Some content goes here</MoreXML>
</MyXMLTag>]]></pre>

Thanks to all for the help!

Matso
Post Reply