Dealing with XML namespace in Javascript

JavaScript++かも日記: ブログタイトルを読み込む2

If you process XML with Javascript, note that you have to use  getElementsByTagNameNS, but you can’t use getElementsByTagNameNS on IE. The part of sample code for this issue in the linked article is

if(document.all) var wksubject = xdoc.getElementsByTagName("dc:subject")
else var wksubject = xdoc.getElementsByTagNameNS( ns_dc ,"subject")

(The sample code in the article is RSS reader.)

Dealing with XML namespace in Javascript

Markdown viewer

I have tried several ways to write and organize my personal memo. I used to use Twiki, Trac, etc. But wiki is too much. You have to set up web server and write document on your browser. So I wanted another way which is easier than wiki. I was looking for something like this. The data is text file, but it’s possible to customize the presentation.

I found that Markdown is the one. I can write it as text. And I can customize the design with css when I need to. So I’ve written markdown viewer with simple HTML and Javascript (Javascript with jQuery and Showdown.)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="ja" xml:lang="ja">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" type="text/css" media="screen" href="" />
  <title>Markdown Viewer</title>
  <div id="markdownContents"></div>
  <!-- Load Javascript libraries -->
  <script type="text/javascript" src="./jquery-1.2.3.js"></script>
  <script type="text/javascript" src="./showdown.js"></script>
  <!-- Main -->
  <script type="text/javascript">
  // Load Markdown contents
  var directory = "./path/to/markdown/docs";
  var filename  = "filename.txt";
  var path      = directory + "/" + filename;md2html(path);
  function md2html(path){
      // Load contents and convert to HTML
      $("#markdownContents").load(path, function(text, status){
          var sdconv     = new Showdown.converter();
          this.innerHTML = sdconv.makeHtml(text);
Markdown viewer

Simple rule for deciding what logic to put where

Best Practices in MVC Design with CakePHP

Anything that doesn’t deal in some way with your application’s core business logic (i.e. session …When you are not sure if you should put a logic into model or controller, here is a good rule to remember.

Anything that doesn’t deal in some way with your application’s core business logic (i.e. session management, request/response handling, certain aspects of security and access control) should stay in the controller; just about everything else can go in the model.

(via CakePHPを使ったMVC設計のベストプラクティス)

Simple rule for deciding what logic to put where

Assign an HTML file to the Internet zone

When you open HTML file with Javascript from local HDD, you see security alert at the top of browser window. To avoid this, put the following strings at the top of your HTML file.

<!-- saved from url=(0014)about:internet -->

The ‘14’ represents character length of ‘about:iternet’.

Thanks JavaScript++かも日記, see also How to strengthen the security settings for the Local Machine zone in Internet Explorer.

Assign an HTML file to the Internet zone

Five reflections

Gosei (5 reflections) is 5 questions to reflect a day by student of bluejacket school in the early Showa Era. The linked article describes that the good point of this is evaluation of your attitude. Here is my translation.

  1. Were you sincere?
  2. Were you true to your word?
  3. Were you full of spirit?
  4. Did you do your best?
  5. Did you scamp your work?

According to wikipedia, the following translations are posted up a notice in United States Naval Academy.

  1. Hast thou not gone against sincerity?
  2. Hast thou not felt ashamed of thy words and deeds?
  3. Hast thou not lacked vigour?
  4. Hast thou exerted all possible efforts?
  5. Hast thou not become slothful?
Five reflections

Illustration of open source licenses

The linked article explained characteristics of several open source licenses and possible combination of it when you use it. The following licenses are explained with illustration.

  1. GPL
  2. LGPL
  3. MPL (and CPL, EPL)
  4. MIT license and BSD license

And CC (Creative Commons) is also explained in the article.

Summarizing basics of these license according to the article,


  • If a software contains GPL licensed code, the software must be published under GPL lincense
  • If a software use a library under non GPL license with GPL licensed software, the license of the library must have compatible with GPL.


  • If a software uses LGPL library as independent binary file(s), you can publish the software under another license. But the LGPL library it self must be published under LGPL license.
  • If a software contains LGPL library in one binary, the software must be published under LGPL lincense.


  • If a software uses MPL licensed code and the source files are separated,  the software can be published under another license.
  • If a software includes MPL licensed code in its source code, the software must not be published another license which is incompatible with MPL.

MIT and BSD license

  • A software can be published under any licenses if it describes copyright and it’s used with self-responsibility.

(These sentences might contain something weird expression. Please confirm by yourself when you use some of these licenses.)

Another good reference of license compatibility is at Wikipedia – List of software licenses.

Illustration of open source licenses