顯示具有 XML 標籤的文章。 顯示所有文章
顯示具有 XML 標籤的文章。 顯示所有文章

解決jdom輸出時產生無意義(空白)Namespace之問題

在新版的jdom(我用的時候是1.1)中,使用XMLOutputter來輸出整個XML Document時,在Element上會產生空白內容的Namespace,像是這樣:

<bean xmlns=""></bean>
不管是呼叫Element的removeNamespaceDeclaration()或是設定NO_NAMESPACE都沒有用,甚至在create element之後呼叫remove attribute()去remove xmlns屬性也不行,這案情不單純阿...。

後來Google到一篇,裡面說到jdom新版有bug,要去source code裡面解決,不過也沒說是什麼問題,只好自己來啦!好險並不是很困難,原因在於XMLOutputter這支code裡面出了問題,在XMLOutputter中,有一個方法叫printNamespace,裡面原本的code有一段是長這樣:



很明顯有了錯,改成下面這樣就可以了:

Why HTML is not good at representing Information on the Internet?

I try to use the following contents to explain why HTML is not good at representing the Information on the Internet. On the other hand, I want to show you why we replace HTML with XML.

HTML is good at showing the layout of the Web Page. For example, we can use the , tags to represent the table form on the Internet. In other words, HTML is suitable to show the docuements to users. But, if we want to use HTML to exchange informations, it will be very difficult.

See the following HTML :

<tr>

<td> aaa </td>
<td> bbb </td>

</tr>

It will show a table on the web page when we use and tags.

Now, we will use a crawlers to grab some informations from many web pages and show the information to our customers, it will be very very difficult to write the program. Because different web pages will use different HTML tags to represent data. The page A use <td> and page B use < ul>. Our program have to deal with different situations...damn it!

If we can use some meaningful tags such as tag to represent the price and tag to represnt the name, it will be great!

XML can make the world better.