Insert \ paste XML code sample in topic w orig formatting?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
daicehawk
Propeller Head
Posts: 23
Joined: Mon May 17, 2010 1:22 pm

Insert \ paste XML code sample in topic w orig formatting?

Post by daicehawk »

Hello all,
Sorry if that question has been already discussed here. I have not found it.
I am trying to insert a complete XML schema file into a topic.
First, Flare recognized it as native XML code and tries to parse it and I had the "Wrong XML declaration" message dialog appearing on the screen.
Then I was advised to use CDATA tag as described here: http://www.w3schools.com/xml/xml_cdata.asp
In this case, Flare does not parse the code, but all the formatting (indentation) is lost.
So what I get in the topic looks like the attachment pic below. I would like to keep the formatting and have Flare not parse the XML code. Any advice? :(
You do not have the required permissions to view the files attached to this post.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by ChoccieMuffin »

An ignorant newbie speaking here, there's something about <div> that you should look at (so I have read) but I have no idea what. That might give you a starting point though, so hope it's of some use.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Andrew
Propellus Maximus
Posts: 1237
Joined: Fri Feb 10, 2006 5:37 am

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by Andrew »

ChoccieMuffin wrote:An ignorant newbie speaking here, there's something about <div> that you should look at (so I have read) but I have no idea what. That might give you a starting point though, so hope it's of some use.
You could *try* enclosing it in <pre></pre> tags -- that typically causes an html parser not to ignore extra whitepace elements (by default html ignores any whitespace elements beyond a single space).
Flare v6.1 | Capture 4.0.0
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by NorthEast »

I would try using a pre tag.

1. Copy the text to the clipboard.
2. In Flare, select the pre style.
3. Select Paste, then choose Paste as inline text.
daicehawk
Propeller Head
Posts: 23
Joined: Mon May 17, 2010 1:22 pm

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by daicehawk »

OK,
so far I enclosed CDATA tag with the <pre> tag. Works fine.
perhaps anybody knows how to make the code highlighted? I mean, not code in general but this specific XML code. I am afraid it might be tricky\impossible to do.
You do not have the required permissions to view the files attached to this post.
Andrew
Propellus Maximus
Posts: 1237
Joined: Fri Feb 10, 2006 5:37 am

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by Andrew »

There are ways to get XML syntax highlighting / coloring in html, but I'm not familiar with any. A quick google search turned up this, but I have no idea if it would work for you:
http://tohtml.com/xml/

If that doesn't work, you may be able to do some more searching (the google search I used was xml syntax highlighting in html) to find something that works.
Flare v6.1 | Capture 4.0.0
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by NorthEast »

daicehawk wrote:perhaps anybody knows how to make the code highlighted? I mean, not code in general but this specific XML code. I am afraid it might be tricky\impossible to do.
If you mean manually, just highlight it as you would any other text; e.g. use span tags.

As Andrew mentioned, there are quite a few online tools that will highlight code.
BaritoneJP
Propeller Head
Posts: 49
Joined: Mon Jun 02, 2008 9:12 am
Contact:

Re: Insert \ paste XML code sample in topic w orig formatting?

Post by BaritoneJP »

Andrew wrote:There are ways to get XML syntax highlighting / coloring in html, but I'm not familiar with any. A quick google search turned up this, but I have no idea if it would work for you:
http://tohtml.com/xml/

If that doesn't work, you may be able to do some more searching (the google search I used was xml syntax highlighting in html) to find something that works.
I used this site and it worked really well ... I had to replace all the single quotes with double quotes in order for Flare to like it but after that (using NotePad++) it worked fine. You also have to add the

Code: Select all

xml:space="preserve"
to the pre tag and then fix the tabs that were messed up by the copy paste.

:D
Thank you for your comments and help with my quandary ...
Jamey
moshe
Propeller Head
Posts: 45
Joined: Tue Apr 05, 2016 10:10 pm
Location: Jerusalem, Israel

Re: Insert \ paste XML code sample in topic w orig formattin

Post by moshe »

Dave Lee wrote:I would try using a pre tag.

1. Copy the text to the clipboard.
2. In Flare, select the pre style.
3. Select Paste, then choose Paste as inline text.
Dave's post is correct, but maybe a bit too concise, to the point of being cryptic.
The most complete explanation of this procedure that I have seen is in the following post from Nita Beck:
viewtopic.php?f=6&t=20603

In summary:
1. Start a new paragraph and style the paragraph with the <pre> style (listed at the bottom of the Style window). Contents pasted in the <pre> block (paragraph) should retain their formatting, including any spaces and line breaks.
2. Copy and paste the code into the <pre> block (paragraph). Flare will insert the code as a bunch of <p> blocks for no reason, but DON’T PANIC!
3. Immediately look for the little Paste icon that appears just below and to the right of the last block added. Click the icon to open a little drop-down menu, and select Paste Inline Text. All of the pasted code should now be within the <pre> block with the original formatting.
Moshe Davis
Jerusalem, Israel
moshe
Propeller Head
Posts: 45
Joined: Tue Apr 05, 2016 10:10 pm
Location: Jerusalem, Israel

Re: Insert \ paste XML code sample in topic w orig formattin

Post by moshe »

I just posted a solution to the exact original problem, using a combination of <pre> and CDATA, in a different thread:
viewtopic.php?f=6&t=29397#p128600
Moshe Davis
Jerusalem, Israel
Post Reply