Upload
kmiyako
View
423
Download
3
Embed Size (px)
DESCRIPTION
2010年3月3日デベロッパ・カンファレンス資料。
All About XSLT4D デベロッパカンファレンス 2010
Clichy/2010-02-03
All About XSLT
•このセッションの内容‣ XSLTの概要
‣ XSLTの利点
‣ XSLTと4D
‣ XSLTの作成, 編集, 検証
‣ XSLTの応用
Clichy/2010-02-03
XSLTの概要
•XMLを他の標準テキスト形式に変換するための言語
XML XSL TEXT
Clichy/2010-02-03
XSLTの概要
•XMLを他の標準テキスト形式に変換するための言語
XML XSL XMLTEXTXSLTEXTXSL HTMLXML
Clichy/2010-02-03
XSLTの利点
•XMLを解析, 再構成, 統計, 並び替え, グループ...
•XMLのノードタイプすべてに対してアクセス...
✦xPathは強力なクエリ言語
✦コメントの出力OK=4D HTML TAGS !
•XMLを変換するための標準の技術
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>
ヨーロッパイギリス
英語
フランス仏語
アフリカカメルーン
仏語ガボン
英語仏語
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>
ヨーロッパイギリス
英語
フランス
アフリカ
カメルーンガボン
仏語
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>
ヨーロッパイギリス
フランス
アフリカ
カメルーン
ガボン仏語
サンプル
XSLTの概要
Clichy/2010-02-03
XSLTの概要
•XML形式で記述するプログラム言語
‣ 実行前にXML妥当性検証, 解析, コンパイル
‣ 要素はコマンド
‣ 属性は命名引数
‣ 要素値は数が定まらない引数
Clichy/2010-02-03
XSLTの概要<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id>1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>
Clichy/2010-02-03
XSLTの概要<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id>1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>
コマンド
Clichy/2010-02-03
XSLTの概要<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id>1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>
リテラルな出力
Clichy/2010-02-03
XSLTの概要
xPath
<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id>1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>
Clichy/2010-02-03
XSLTの概要
関数
<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id>1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>
Clichy/2010-02-03
XSLTの概要
変数/引数
<xsl:template match=”/”><data> <xsl:for-each select=”//*[@id>1]”> <month id=”{@id}”> <xsl:value-of select=”name($name)” /> </month> </xsl:for-each></data></xsl:template>
XSLTと4D
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’”
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’”
一時ファイル必要なし
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(‘’)
XSLT+SVG
Clichy/2010-02-03
DOM
SAX
XSLT
document
BLOB
PICTURE
TEXT
微妙な関係!?
Clichy/2010-02-03
DOM
SAX
XSLT
document
BLOB
PICTURE
TEXT
微妙な関係!?
Clichy/2010-02-03
DOM
SAX
XSLT
document
BLOB
PICTURE
TEXT
微妙な関係!?
Clichy/2010-02-03
DOM
SAX
XSLT
document
BLOB
PICTURE
TEXT
微妙な関係!?
Clichy/2010-02-03
SAX
XSLT
BLOB
PICTURE
TEXT
document
DOM
Regex
SVG (get)
SVG (own copy)
SVG interactive
SVG animatable
微妙な関係!?
xPath
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。
Clichy/2010-02-03
xPath
•/preceding-sibling::*
•/element/@attribute
•/*/@*
•*[name()=‘table’ and @id=‘1’]
•*[matches(@uuid,(‘[0-9a-f]{32}’))]
ワイルドカード
属性
プレディケート
軸
正規表現
Clichy/2010-02-03
xPath
•/preceding-sibling::*
•/element/@attribute
•/*/@*
•*[name()=‘table’ and @id=‘1’]
•*[matches(@uuid,(‘[0-9a-f]{32}’))]
ワイルドカード
属性
プレディケート
軸
正規表現
1.0
XSLTリファレンス
Clichy/2010-02-03
コマンド
Clichy/2010-02-03
<xsl:if test=”xPath”> ...some code here</xsl:if>
コマンド条件分岐
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>
コマンド条件分岐
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>
コマンドクエリ, 並び替え
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>
コマンドクエリ, 一括更新
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>
コマンドサブルーチン
Clichy/2010-02-03
<xsl:value-of select=”xPath” />
コマンド出力
Clichy/2010-02-03
<xsl:text>...literal value here</xsl:text>
or,here
<tag></tag>
コマンド出力
Clichy/2010-02-03
<xsl:number count=”xPath” format=””/>//context based value
<xsl:number value=”” format=””/>//static value
コマンド出力
Clichy/2010-02-03
<xsl:output method=”xml|text|html” />
encodingstandaloneindentomit-xml-declarationdoctype-publicdoctype-systemmedia-type
コマンド設定
xPathリファレンス
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>
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Clichy/2010-02-03
関数
Clichy/2010-02-03
number, format-numbersumroundceilingfloor
numeric: string:node:xml:
settings:
関数
Clichy/2010-02-03
string, namecontains, starts-withconcatsubstringsubstring-beforesubstring-afternormalize spacetranslate
numeric: string:node:xml:
settings:
関数
Clichy/2010-02-03
positionlastdocument
numeric: string:node:xml:
settings:
関数
Clichy/2010-02-03
namespace-uriunparsed-entity-uri
numeric: string:node:xml:
settings:
関数
Clichy/2010-02-03
system-propertyfunction-available
numeric: string:node:xml:
settings:
関数
Clichy/2010-02-03
EXSLT 拡張関数
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 拡張関数
Clichy/2010-02-03
str:encode-uristr:decode-uristr:paddingstr:concatstr:align
math: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
set:differenceset:distinctset:has-same-nodeset:intersectionset:leadingset:trainling
math: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
dyn:evaluatemath: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
date:date-timemath: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
exsl:object-typeexsl:node-set
math: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
math: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
math: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
math: str:set:
dyn:date:exsl:
random:func:
regexp:
EXSLT 拡張関数
Clichy/2010-02-03
exsl4D: exsl4D:format-numberexsl4D:format-valueexsl4D:maxexsl4D:minexsl4D:max-string-lengthexsl4D:max-value-length
4D 拡張関数