[jena] how to read seq
October 24th, 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
[jena] how to write seq
October 24th, 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.
[jena] minimum rdf
October 20th, 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>
[LAMP + Ajax] naming rule
October 4th, 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
In Javascript
strTopic (string), elmTopic (element), objTopic (object)
str_topic (string), elm_topic (element), obj_topic (object)
[javascript] incident bug
September 30th, 2007
When we use setAttribute, getAttribute, removeAttribute in IE, readonly should be readOnly. Same things happen in maxLength, bgColor, and so on.
[javascript] solve browser incompatibility
September 20th, 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
- tag id name: xxx_id
- javascript variable: elmXXX (like hangarian style?)
- tag class name: xxx_class
If someone has good idea, please let me know.
[javascript] color compatibility of IE and Firefox
September 19th, 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)
[mysql] sql query: combine two table
August 28th, 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
[eclipse] divide editor window
August 25th, 2007
1. right click editor tab.
2. select “New Editor”.
3. drag down to status bar.
[php] dynamic class loading
August 18th, 2007
When you want to load MyClass via string variant,
$classname = "MyClass";
$object = new $classname();
Next Page »







