Archive for 2007

Next Page »

[jena] how to read seq

24 October 2007

jena can read seq from rdf file.

If there is following rdf,


<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
  <rdf:Description rdf:about="http://www.illigal.uiuc.edu/saru">
    <rdf:_3>Uncategorized</rdf:_3>
    <rdf:_2>programming</rdf:_2>
    <rdf:_1>Books</rdf:_1>
    <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq"/>
  </rdf:Description>
</rdf:RDF>

And, you execute following code,


Model model = ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open("sample.rdf");
model.read(in, "");

seq = model.getSeq("http://www.illigal.uiuc.edu/saru");

for(int i = 1; i <= seq.size(); i++){
    System.out.println(i + ": " + seq.getObject(i));
}

output will be

1: Books
2: programming
3: Uncategorized

No Comments »

[jena] how to write seq

24 October 2007

JENA can make list using seq on RDF.


Model model = ModelFactory.createDefaultModel();        

Seq seq = model.createSeq("http://www.illigal.uiuc.edu/saru");
seq.add("Books");
seq.add("programming");
seq.add("Uncategorized");

model.write(System.out);

We can create seq by Model::createSeq. Arguments is description URI. If you execute previous code,


<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
  <rdf:Description rdf:about="http://www.illigal.uiuc.edu/saru">
    <rdf:_3>Uncategorized</rdf:_3>
    <rdf:_2>programming</rdf:_2>
    <rdf:_1>Books</rdf:_1>
    <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq"/>
  </rdf:Description>
</rdf:RDF>

will be output. _1, _2, _3 is order of the objects.

No Comments »

[jena] minimum rdf

20 October 2007


Model model = ModelFactory.createDefaultModel();        

model.write(System.out);

this outputs


<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
</rdf:RDF>

No Comments »

[LAMP + Ajax] naming rule

4 October 2007

I couldn’t find naming rule for LAMP + Ajax. So, I am making my naming rule. This rule might reduce bugs in javascript and php.

In HTML tags

  • tag id attribute must be lower case and finished at “_id”
  • tag class attribute name must be finished at “_class”
  • tag name attribute is not added anything.
  • In Javascript

  • local variant must be Hungarian notation with mixed lower case and upper case without _
  • strTopic (string), elmTopic (element), objTopic (object)

  • global vaiant must be Hungrian notation with only lower case and _
  • str_topic (string), elm_topic (element), obj_topic (object)

    WordPress

    No Comments »

    [javascript] incident bug

    30 September 2007

    When we use setAttribute, getAttribute, removeAttribute in IE, readonly should be readOnly. Same things happen in maxLength, bgColor, and so on.

    No Comments »

    [javascript] solve browser incompatibility

    20 September 2007

    Color

    use rgb color parser

    Event

    use Event class in prototype.js

    Element

    don’t use same tag id name, javascript variable name, and tag class name, and use Element class and $() in prototype.js.
    I think we need naming rule at id name, variable name, and class name.
    like

    If someone has good idea, please let me know.

    No Comments »

    [javascript] color compatibility of IE and Firefox

    19 September 2007

    javascript sometimes makes browser depended color compatibility problem.

    This javascript library solves the problem.
    http://www.phpied.com/rgb-color-parser-in-javascript/

    It’s like

    var el = document.getElementById("mycolor");
    var color = new RGBColor(el.style.backgroundColor);
    alert(color.toHex()); // #cccccc
    alert(color.toRGB()); // rgb(204,204,204)

    No Comments »

    [mysql] sql query: combine two table

    28 August 2007

    combine two tables, count specific values, order by the count, and show only top 10.

    SELECT table1.comment_id comment_id, count(table1.comment_id) point, parent_id, subparent_id, text FROM table1 LEFT JOIN comments ON table1.comment_id=table2.comment_id WHERE board_id=1 GROUP BY table1.comment_id ORDER BY point DESC LIMIT 10

    No Comments »

    [eclipse] divide editor window

    25 August 2007

    1. right click editor tab.

    eclipse1

    2. select “New Editor”.

    eclipse2

    eclipse3

    3. drag down to status bar.

    eclipse4

    eclipse5

    1 Comment »

    [php] dynamic class loading

    18 August 2007

    When you want to load MyClass via string variant,

    $classname = "MyClass";
    $object = new $classname();

    No Comments »

    Next Page »