71
All About XSLT 4D デベロッパカンファレンス 2010

XSLT 2010-03-03

  • Upload
    kmiyako

  • View
    424

  • Download
    3

Embed Size (px)

DESCRIPTION

2010年3月3日デベロッパ・カンファレンス資料。

Citation preview

Page 1: XSLT 2010-03-03

All About XSLT4D デベロッパカンファレンス 2010

Page 2: XSLT 2010-03-03

Clichy/2010-02-03

All About XSLT

•このセッションの内容‣ XSLTの概要

‣ XSLTの利点

‣ XSLTと4D

‣ XSLTの作成, 編集, 検証

‣ XSLTの応用

Page 3: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要

•XMLを他の標準テキスト形式に変換するための言語

XML XSL TEXT

Page 4: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要

•XMLを他の標準テキスト形式に変換するための言語

XML XSL XMLTEXTXSLTEXTXSL HTMLXML

Page 5: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの利点

•XMLを解析, 再構成, 統計, 並び替え, グループ...

•XMLのノードタイプすべてに対してアクセス...

✦xPathは強力なクエリ言語

✦コメントの出力OK=4D HTML TAGS !

•XMLを変換するための標準の技術

Page 6: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの利点<region name="ヨーロッパ">! <country name="イギリス">! ! <language name="英語">! </country>! <country name="フランス">! ! <language name="仏語">! </country></region><region name="アフリカ">! <country name="カメルーン">! ! <language name="仏語" />! ! <language name="英語" />! </country>! <country name="ガボン">! ! <language name="仏語">! </country></region>

ヨーロッパイギリス

英語

フランス仏語

アフリカカメルーン

仏語ガボン

英語仏語

Page 7: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの利点<language name="英語">! <region name="ヨーロッパ">! ! <country name="イギリス"/>! </region>! <region name="アフリカ">! ! <country name="カメルーン"/>! </region></language><language name="仏語">! <region name="ヨーロッパ">! ! <country name="フランス"/>! </region>! <region name="アフリカ">! ! <country name="ガボン"/>! ! <country name="カメルーン"/>! </region></language>

ヨーロッパイギリス

英語

フランス

アフリカ

カメルーンガボン

仏語

Page 8: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの利点

<country name="イギリス" region="ヨーロッパ">! ! <language name="英語"/></country><country name="ガボン" region="アフリカ">! ! <language name="仏語"/></country><country name="カメルーン" region="アフリカ">! ! <language name="仏語"/>! ! <language name="英語"/></country><country name="フランス" region="ヨーロッパ">! ! <language name="仏語"/></country>

ヨーロッパイギリス

フランス

アフリカ

カメルーン

ガボン仏語

Page 9: XSLT 2010-03-03

サンプル

Page 10: XSLT 2010-03-03

XSLTの概要

Page 11: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要

•XML形式で記述するプログラム言語

‣ 実行前にXML妥当性検証, 解析, コンパイル

‣ 要素はコマンド

‣ 属性は命名引数

‣ 要素値は数が定まらない引数

Page 12: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id&gt;1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>

Page 13: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id&gt;1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>

コマンド

Page 14: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id&gt;1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>

リテラルな出力

Page 15: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要

xPath

<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id&gt;1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>

Page 16: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要

関数

<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id&gt;1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>

Page 17: XSLT 2010-03-03

Clichy/2010-02-03

XSLTの概要

変数/引数

<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id&gt;1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>

Page 18: XSLT 2010-03-03

XSLTと4D

Page 19: XSLT 2010-03-03

Clichy/2010-02-03

XSLTと4D

•APPLY XSLT TRANSFORMATION‣ Apache xalan-c‣ XSLT 1.0‣ BLOB; BLOB; BLOB‣ path; path; path

•SET XSLT PARAMETER‣ “12345”‣ “‘abc’”

Page 20: XSLT 2010-03-03

Clichy/2010-02-03

XSLTと4D

•APPLY XSLT TRANSFORMATION‣ Apache xalan-c‣ XSLT 1.0‣ BLOB; BLOB; BLOB‣ path; path; path

•SET XSLT PARAMETER‣ “12345”‣ “‘abc’”

一時ファイル必要なし

Page 21: XSLT 2010-03-03

Clichy/2010-02-03

XSLTと4D

•APPLY XSLT TRANSFORMATION‣ Apache xalan-c‣ XSLT 1.0‣ BLOB; BLOB; BLOB‣ path; path; path

•SET XSLT PARAMETER‣ “12345”‣ “‘abc’”

一時ファイル必要なしコンパイルをキープ

import, include

document(‘’)

Page 22: XSLT 2010-03-03

XSLT+SVG

Page 23: XSLT 2010-03-03

Clichy/2010-02-03

DOM

SAX

XSLT

document

BLOB

PICTURE

TEXT

微妙な関係!?

Page 24: XSLT 2010-03-03

Clichy/2010-02-03

DOM

SAX

XSLT

document

BLOB

PICTURE

TEXT

微妙な関係!?

Page 25: XSLT 2010-03-03

Clichy/2010-02-03

DOM

SAX

XSLT

document

BLOB

PICTURE

TEXT

微妙な関係!?

Page 26: XSLT 2010-03-03

Clichy/2010-02-03

DOM

SAX

XSLT

document

BLOB

PICTURE

TEXT

微妙な関係!?

Page 27: XSLT 2010-03-03

Clichy/2010-02-03

SAX

XSLT

BLOB

PICTURE

TEXT

document

DOM

Regex

SVG (get)

SVG (own copy)

SVG interactive

SVG animatable

微妙な関係!?

Page 28: XSLT 2010-03-03

xPath

Page 29: XSLT 2010-03-03

Clichy/2010-02-03

‣ DOM Create XML element‣ DOM Find XML element‣ DOM SET XML VALUE

xPath•XMLコマンドはxPathサポートしている?

http://www.4d.com/docs/CMJ/CMJ10099.HTM

4DではElement[ElementNum]シンタックスを使用した添字によるXPath要素へのアクセスも使用できます。例えば以下の構造があるとき:

   <RootElement>      <Elem1>         <Elem2>aaa</Elem2>         <Elem2>bbb</Elem2>         <Elem2>ccc</Elem2>      </Elem1>   </RootElement>

XPath記法では /RootElement/Elem1/Elem2[3] シンタックスを使用して"ccc"値にアクセスできます。

•element[index]‣ インデックスで要素が参照できるだけ。

‣ それ以外のxPathはNG。

Page 30: XSLT 2010-03-03

Clichy/2010-02-03

xPath

•/preceding-sibling::*

•/element/@attribute

•/*/@*

•*[name()=‘table’ and @id=‘1’]

•*[matches(@uuid,(‘[0-9a-f]{32}’))]

ワイルドカード

属性

プレディケート

正規表現

Page 31: XSLT 2010-03-03

Clichy/2010-02-03

xPath

•/preceding-sibling::*

•/element/@attribute

•/*/@*

•*[name()=‘table’ and @id=‘1’]

•*[matches(@uuid,(‘[0-9a-f]{32}’))]

ワイルドカード

属性

プレディケート

正規表現

1.0

Page 32: XSLT 2010-03-03

XSLTリファレンス

Page 33: XSLT 2010-03-03

Clichy/2010-02-03

コマンド

Page 34: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:if test=”xPath”> ...some code here</xsl:if>

コマンド条件分岐

Page 35: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:choose> <xsl:when test=”xPath”> ...some code here </xsl:when> <xsl:when test=”xPath”> ...some code here </xsl:when> <xsl:otherwise> ...some code here </xsl:otherwise></xsl:choose>

コマンド条件分岐

Page 36: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:for-each select=”xPath” > <xsl:for-each select=”xPath” > <xsl:sort select=”xPath” /> <xsl:sort select=”xPath” /> ...some code here </xsl:for-each></xsl:for-each>

コマンドクエリ, 並び替え

Page 37: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:apply-templates select=”xPath” > <xsl:with-param name=”” select=”xPath” /> <xsl:sort select=”xPath” /> <xsl:sort select=”xPath” /></xsl:apply-templates>

<xsl:template match=”xPath” > <xsl:param name=”” select=”xPath” /> ...some code here</xsl:template>

コマンドクエリ, 一括更新

Page 38: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:call-templates name=”” > <xsl:with-param name=”” select=”xPath” /></xsl:apply-templates>

<xsl:template name=”” > <xsl:param name=”” select=”xPath” /> ...some code here</xsl:template>

コマンドサブルーチン

Page 39: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:value-of select=”xPath” />

コマンド出力

Page 40: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:text>...literal value here</xsl:text>

or,here

<tag></tag>

コマンド出力

Page 41: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:number count=”xPath” format=””/>//context based value

<xsl:number value=”” format=””/>//static value

コマンド出力

Page 42: XSLT 2010-03-03

Clichy/2010-02-03

<xsl:output method=”xml|text|html” />

encodingstandaloneindentomit-xml-declarationdoctype-publicdoctype-systemmedia-type

コマンド設定

Page 43: XSLT 2010-03-03

xPathリファレンス

Page 44: XSLT 2010-03-03

Clichy/2010-02-03

軸 (axis)

<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

Page 45: XSLT 2010-03-03

Clichy/2010-02-03

self::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 46: XSLT 2010-03-03

Clichy/2010-02-03

child::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 47: XSLT 2010-03-03

Clichy/2010-02-03

parent::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 48: XSLT 2010-03-03

Clichy/2010-02-03

attribute::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 49: XSLT 2010-03-03

Clichy/2010-02-03

ancestor::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 50: XSLT 2010-03-03

Clichy/2010-02-03

descendant::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 51: XSLT 2010-03-03

Clichy/2010-02-03

preceding-sibling::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 52: XSLT 2010-03-03

Clichy/2010-02-03

preceding::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 53: XSLT 2010-03-03

Clichy/2010-02-03

following-sibling::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 54: XSLT 2010-03-03

Clichy/2010-02-03

following::*<root> <trunk index=”1”> <branch name=”abc”> <trunk index=”2” /> <branch name=”4D” version=”11”> <leaf> <vein /> <leaf> </branch> </trunk> <trunk index=”3” /></root>

軸 (axis)

Page 55: XSLT 2010-03-03

Clichy/2010-02-03

関数

Page 56: XSLT 2010-03-03

Clichy/2010-02-03

number, format-numbersumroundceilingfloor

numeric: string:node:xml:

settings:

関数

Page 57: XSLT 2010-03-03

Clichy/2010-02-03

string, namecontains, starts-withconcatsubstringsubstring-beforesubstring-afternormalize spacetranslate

numeric: string:node:xml:

settings:

関数

Page 58: XSLT 2010-03-03

Clichy/2010-02-03

positionlastdocument

numeric: string:node:xml:

settings:

関数

Page 59: XSLT 2010-03-03

Clichy/2010-02-03

namespace-uriunparsed-entity-uri

numeric: string:node:xml:

settings:

関数

Page 60: XSLT 2010-03-03

Clichy/2010-02-03

system-propertyfunction-available

numeric: string:node:xml:

settings:

関数

Page 61: XSLT 2010-03-03

Clichy/2010-02-03

EXSLT 拡張関数

Page 62: XSLT 2010-03-03

Clichy/2010-02-03

math:min, maxmath:lowest, highestmath:tan, cos, sinmath:atan, acos, asinmath:randommath:absmath:powermath:exp, log, sqrtmath:constant

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 63: XSLT 2010-03-03

Clichy/2010-02-03

str:encode-uristr:decode-uristr:paddingstr:concatstr:align

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 64: XSLT 2010-03-03

Clichy/2010-02-03

set:differenceset:distinctset:has-same-nodeset:intersectionset:leadingset:trainling

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 65: XSLT 2010-03-03

Clichy/2010-02-03

dyn:evaluatemath: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 66: XSLT 2010-03-03

Clichy/2010-02-03

date:date-timemath: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 67: XSLT 2010-03-03

Clichy/2010-02-03

exsl:object-typeexsl:node-set

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 68: XSLT 2010-03-03

Clichy/2010-02-03

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 69: XSLT 2010-03-03

Clichy/2010-02-03

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 70: XSLT 2010-03-03

Clichy/2010-02-03

math: str:set:

dyn:date:exsl:

random:func:

regexp:

EXSLT 拡張関数

Page 71: XSLT 2010-03-03

Clichy/2010-02-03

exsl4D: exsl4D:format-numberexsl4D:format-valueexsl4D:maxexsl4D:minexsl4D:max-string-lengthexsl4D:max-value-length

4D 拡張関数