[HOME]: [Mac OS X]: [MacPython]: [Emacs]: [生存報告記]: [MacEmacs JP Project]: [NTEmacs JP Project]:

Differences between revisions 3 and 4

Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
[http://jakarta.terra-intl.com/commons/jxpath/ JXPath翻訳] [http://www.terra-intl.com/jakarta/commons/jxpath/ JXPath翻訳]
Line 28: Line 28:
というか[http://jakarta.terra-intl.com/commons/jxpath/users-guide.html ユーザガイド]読めばたいがいわかると思います。 というか[http://www.terra-intl.com/jakarta/commons/jxpath/users-guide.html ユーザガイド]読めばたいがいわかると思います。
Line 71: Line 71:
        Iterator authors = context.iterate("authorName[position() > 0]");         Iterator authors = context.iterate("authorName[position() > 0]");
Line 178: Line 178:
[http://crazyclaudia.webpark.pl/mother-son-incest.html mother son incest incest mother son] [http://crazyclaudia.webpark.pl/incest-rape.html free incest photos] [http://crazyclaudia.webpark.pl/incest-tgp.html incest tgp incest xxx] [http://crazyclaudia.webpark.pl/brother-sister-incest.html incest drawings] [http://crazyclaudia.webpark.pl/free-erotic-incest-stories.html free erotic incest stories sister incest] [http://crazyclaudia.webpark.pl/teen-incest.html teen incest incest toons] [http://crazyclaudia.webpark.pl/father-daughter-incest.html father daughter incest emotional incest] [http://crazyclaudia.webpark.pl/stories-of-incest.html stories of incest incest board] [http://crazyclaudia.webpark.pl/incest-forums.html incest forum incest free stories] [http://crazyclaudia.webpark.pl/mature-incest.html mature incest family incest] [http://crazyclaudia.webpark.pl/incest-quest.html incest quest mom son incest] [http://crazyclaudia.webpark.pl/incest-pictures.html incest pictures simpsons incest] [http://crazyclaudia.webpark.pl/incest-videos.html incest videos incest toons] [http://crazyclaudia.webpark.pl/gay-incest.html gay incest family incest] [http://crazyclaudia.webpark.pl/incest-taboo.html incest taboo mom son incest] [http://crazyclaudia.webpark.pl/incest-sex.html incest sex incest rape] [http://crazyclaudia.webpark.pl/mother-and-son-incest.html gay incest stories] [http://crazyclaudia.webpark.pl/incest-sites.html incest sites incest erotica] [http://crazyclaudia.webpark.pl/incest-taboo-forum.html incest taboo incest stories] [http://crazyclaudia.webpark.pl/real-incest.html real incest father daughter incest] [http://crazyclaudia.webpark.pl/free-incest-pictures.html incest pictures incest porno] [http://crazyclaudia.webpark.pl/incest-forum.html incest forum free incest porn] [http://crazyclaudia.webpark.pl/young-incest.html young incest incest comics] [http://crazyclaudia.webpark.pl/incest-pics.html incest pics incest forum] [http://crazyclaudia.webpark.pl/free-incest-videos.html incest videos incest video] [http://crazyclaudia.webpark.pl/family-incest.html family incest xxx incest] [http://crazyclaudia.webpark.pl/incest-sex-stories.html incest sex incest stories] [http://crazyclaudia.webpark.pl/incest-grrl.html incest grrl] [http://crazyclaudia.webpark.pl/incest-porn.html incest porn mom son incest] [http://crazyclaudia.webpark.pl/incest-stories.html incest stories father daughter incest] [http://crazyclaudia.webpark.pl/ free incest galleries]

概要

JavaBeans、Maps、サーブレットコンテキスト、DOMをXPathの仕様にしたがって取得できる。

非常に強力でおもしろい。SQLすきな人にもうけるかもしれない。

URL

http://jakarta.apache.org/commons/jxpath/

JXPath翻訳

インストールと動作確認

jarをクラスパスのある場所におく。

commons-jxpath-1.1.jarを基に解説する。

testを動作させてみるとよい。

ソースからコンパイルする場合はMavenを利用するなら

maven dist

ですべてが一括で作成されて便利です。

利用方法

というかユーザガイド読めばたいがいわかると思います。

JavaBean Property Access

JXpathSample.java

public class JXpathSample {
    public String getTitle() {
        return "title";
    }

    public String[] getAuthorName() {
        String author[] = {"sakito", "python", "emacs"};
        return author;
    }
}

UseSample.java

import org.apache.commons.jxpath.*;
public class UseSample {
    public static void main(String[] args) {
        JXpathSample path = new JXpathSample();
        JXPathContext context = JXPathContext.newContext(path);
        String title = (String) context.getValue("title");
        System.out.println(title);

        // XPathの仕様では最初が1になります。
        String author1 = (String) context.getValue("authorName[1]");
        String author2 = (String) context.getValue("authorName[2]");
        String author3 = (String) context.getValue("authorName[3]");
        System.out.println(author1);
        System.out.println(author2);
        System.out.println(author3);

        // 存在しない値にアクセスすると、JXPathExceptionが発生します。
        //String author4 = (String) context.getValue("authorName[4]");

        // 配列などの複値の場合はiterateで取ります。
        Iterator authors = context.iterate("authorName[position() > 0]");
        for (;authors.hasNext();) {
            System.out.println(authors.next());
        }
    }
}

Nested Bean Property Access

Author.java

public class Author {

    private String name;

    public Author(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }
}

JXpathSample.javaに追加

public Author getAuthor() {
    Author author = new Author("sakito");
    return author;
}

UseSample.javaに追加

String name = (String) context.getValue("author/name");
System.out.println(name);

Map Element Access

Author.javaに追加

public Map getAuthorInfo() {
    Map info = new HashMap();
    info.put("address", "toukyo japan");
    info.put("tel", "03-xxxx-xxxx");
    return info;
}

UseSample.javaに追加

// 文法1
String tel = (String) context.getValue("author/authorInfo/tel");
System.out.println(tel);

// 文法2
String address = (String) context.getValue("author[@name='authorInfo']/address");
System.out.println(address);

// この例ではどちらでも問題ないですが、どちらを利用するかは場合によります。
// XPathの仕様を参照してください。

Setting Properties

値の変更も可能です。

JxpathSample.javaに追加

private String price;
public String getPrice() {
    return this.price;
}

public void setPrice(String price) {
    this.price = price;
}

UseSample.java

context.setValue("price", "2000");
String price = (String) context.getValue("price");
System.out.println(price);

context.setValue("price", "3000");
price = (String) context.getValue("price");
System.out.println(price);

参考サイト

日本語のサイトはJakartaの杜の翻訳以外には今ないかも。

ってか強力なのでおそらく秘密です。

公開しないで利用してるのではなかろうか?


CategoryJava CategoryXml

紹介マニアMoinMoin: JXPath (last edited 2005-02-02 14:56:02 by )