BlogHarbor Home Page
FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  UsergroupsRSS   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
How to display java code and xml document
 
Post new topic   Reply to topic    BlogHarbor Community Forum Index -> Beginner's Lounge
View previous topic :: View next topic  
Author Message
roger_rustin



Joined: 14 Dec 2004
Posts: 10

PostPosted: Mon Jan 03, 2005 9:20 am    Post subject: How to display java code and xml document Reply with quote

1)

I would like to put the java source code in the blog. When I do that the all the indetation goes away. On some other sites (like theserverside.com ) one can put the source code in <code></code> tag. How could I simulate the same behaviour on blogharbor?

2) Similarly I want to display xml document on the blog. When I put
<a> testing tag <a/> , I get to see only the "testing tag" and the actual tags are not see which is understable. How could I convey the message to not to parase any tag and to dump the whole document as it is (keeping th xml format intact).

Thanks.
- Roger
Back to top
View user's profile Send private message
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Mon Jan 03, 2005 11:30 am    Post subject: Re: How to display java code and xml document Reply with quote

If you are using the Rich Text Editor (RTE) which allows you to enter your blog post in a What-You-See-Is-What-You-Get format, you will need to take some extra steps to make sure the output is what you are looking for.

When you are entering text into the Rich Text Editor, you are in Display Mode. Display Mode allows you to see that the HTML output looks like as you enter the article. If you want to see the underlying source code which creates that output, you need to click a button to go into Source Mode. This page from the manual shows you how.

Alternatively, you can turn off the Rich Text Editor and enter your HTML code directly. You can disable the Rich Text Editor by accessing your control panel from Settings & Security > Advanced. Look for the checkbox for Enable Rich Text Editor and uncheck it, then click Save Settings. You should be able to enter HTML more easily with the simple editor.

Now, that's the background. To answer your questions: In your first question, you are asking how to enter HTML tags directly. You can either enter your HTML tags within the RTE by switching to Source Mode and adding the tags, or by disabling the RTE and entering your HTML-formatted text into the simpler editor. You might want to use <PRE> rather than <CODE> if you need preserve indents.

In your second question, you are asking the opposite: How do I enter HTML (or XML) tags into an article but have them not parsed by the browser, but displayed as is? To do that, you would need to escape the html tags. This is true for all web browsers and web services, the need to escape tags if you want them to appear on your page is not unique to our service.

If you want this:

Code:
<a> testing tag <a/>


to appear on your page, you need to convert the left and right carets to special codes:

Code:
&lt;a&gt; testing tag &lt;a/&gt;


These codes will be created for you if you just paste your HTML into the RTE in Display Mode, as it will assume you want to show the codes and not use the HTML. If you are using the simpler editor, you would need to enter the escaped HTML directly.

That should sum things up, I hope. You might want to look at using ecto for Mac or Blogjet for Windows for posting to your blog, these blogging editors can make posting more complex articles easier when compared with using a web-based editor.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
roger_rustin



Joined: 14 Dec 2004
Posts: 10

PostPosted: Wed Jan 05, 2005 8:54 pm    Post subject: Reply with quote

The <pre> </pre> tag is not working for me. check out the source code for
http://weblog .neeraj.name/blog/_archives/2005/1/5/232144.html

The source code contains an xml file within the pre anchor tag. Any suggestion.

thanks.
-
Back to top
View user's profile Send private message
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Wed Jan 05, 2005 9:38 pm    Post subject: Reply with quote

In re-reading my earlier post, I think I might have suggested that using PRE would make it so that you do not have to escape your HTML, that is not the case. The fact is that if you want to output XML/HTML to a browser, all browsers require that you escape the HTML first, otherwise the browser tries to interpret the HTML codes. This is not just the way our service works, it's the way browsers work...

So if you have the following text:

Code:
<hibernate-mapping>
   <class table="parent4" name="example4.Parent4">
      <id name="id" unsaved-value="0" type="long" column="pid">
         <generator class="identity"></generator>
         <set name="children" inverse="true" cascade="none">
            <key column="pid">
               <one-to-many class="example4.Child4"></one-to-many>
            </key>
         </set>
      </id>
   </class>
</hibernate-mapping>


that you want to be displayed in the browser as above, the actual HTML code that would do so is this:

Code:
<pre>
&lt;hibernate-mapping&gt;
   &lt;class table="parent4" name="example4.Parent4"&gt;
      &lt;id name="id" unsaved-value="0" type="long" column="pid"&gt;
         &lt;generator class="identity"&gt;&lt;/generator&gt;
         &lt;set name="children" inverse="true" cascade="none"&gt;
            &lt;key column="pid"&gt;
               &lt;one-to-many class="example4.Child4"&gt;&lt;/one-to-many&gt;
            &lt;/key&gt;
         &lt;/set&gt;
      &lt;/id&gt;
   &lt;/class&gt;
&lt;/hibernate-mapping&gt;
</pre>


I had pretty good success just pasting in the raw code from the first example into the Rich Text HTML editor in the regular Display Mode, it did a pretty good job escaping the text for me... Again, you might want to try using Blogjet to see if it works better for you when posting this type of more sophisticated post.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Search all BlogHarbor support resources.
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    BlogHarbor Community Forum Index -> Beginner's Lounge All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum