Documente Academic
Documente Profesional
Documente Cultură
Programmers Reference
Second Edition
Michael Kay
XSLT
2002
XSLT.
. , . ,
. , .
.
.
.
.
.
.
.
.
XSLT. . . . : , 2002.
1016 ., .
ISBN 5932860391
XML
XML. W3C
XSLT ,
, . :
XSLT Microsoft, Oracle Apache Software
Foundation. , XSLT Saxon,
XSLT,
.
:
XSLT, , ;
XSLT
;
; , XSLT
.
, XML HTML
XSLT
.
ISBN 5932860391
ISBN 1861005067 ()
, 2002
Authorized translation of the English edition 2001 Wrox Press Ltd. This translation
is published and sold by permission of Wrox Press Ltd, the owner of all rights to pub
lish and sell the same.
,
.
, , .
. 193148, , . , 4,
. (812) 3245353, edit@symbol.ru. N 000054 25.12.98.
00593, 2; 953000 .
28.03.2002. 701001/16 .
. 63,5 . . 2000 . N
199034, , 9 , 12.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1. XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
XSLT? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
XSLT XML? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
XSLT XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
XSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
XSLT 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
XSLT . . . . . . . . . . . . . . . . . . . . . . . . . 57
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2. XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
XSLT: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
, . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
<xsl:stylesheet> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
<?xmlstylesheet?> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
4. XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
xsl:applyimports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
xsl:applytemplates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
xsl:attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
xsl:attributeset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
xsl:calltemplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
xsl:choose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
xsl:comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
xsl:copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
xsl:copyof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
xsl:decimalformat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
xsl:document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
xsl:element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
xsl:fallback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
xsl:foreach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
xsl:if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
xsl:import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
xsl:include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
xsl:key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
xsl:message. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
xsl:namespacealias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
xsl:number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
xsl:otherwise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
xsl:output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
xsl:param . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
xsl:preservespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
xsl:processinginstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
xsl:script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
xsl:sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
xsl:stripspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
xsl:stylesheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
xsl:template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
xsl:text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
xsl:transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
xsl:valueof. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
xsl:variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
xsl:when . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
xsl:withparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
(AbsoluteLocationPath) . . . . . . . . . . . . . . . . . . . . 390
(AdditiveExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
(Argument) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
(FunctionCall) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
(Expr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
(AndExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
(OrExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
(UnionExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
(RelationalExpr). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
(PathExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
(EqualityExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
(NCName) (NCNameChar) . . 416
(OperatorName) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
(FunctionName) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
(NameTest) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
(NodeTest) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
(Literal) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
(LocationPath) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
(MultiplicativeExpr) . . . . . . . . . . . . . . . . . . . . . 428
(AxisName) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
(Operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
(MultiplyOperator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
(RelativeLocationPath) . . . . . . . . . . . . . . . . . . 437
(PrimaryExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
(QName) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
(Predicate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
(PredicateExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
(ExprWhitespace) . . . . . . . . . . . . . . . . . . . . . . 447
(AbbreviatedAbsoluteLocationPath) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
(AbbreviatedRelativeLocationPath) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
(AbbreviatedAxisSpecifier) . . . . . . . . . . . . . . . 452
(AbbreviatedStep) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
(AxisSpecifier) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
(VariableReference) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
(NodeType) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
(UnaryExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
(FilterExpr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
(Digits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
(Number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
(Step) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
(ExprToken) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
(Pattern). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
(LocationPathPattern) . . . . . . . . . . . . . . . . . . . . . . . . 478
(RelativePathPattern) . . . . . . . . . . . . . . . . . . . . . . 480
(StepPattern) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
ChildAttribute (ChildOrAttributeAxisSpecifier) . . . . . . . 487
ID (IdKeyPattern) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
ceiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
concat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
contains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
elementavailable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
false . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
floor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
formatnumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
functionavailable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
generateid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
lang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
last . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
localname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
namespaceuri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
normalizespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
not. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
round . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
startswith . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
stringlength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
substring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
substringafter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
substringbefore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
systemproperty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
translate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
true . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
unparsedentityuri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
8. . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
? . . . . . . . . . . . . . . . . . . . . . 618
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
XPath . . . . . . . . . . . . . . . . . . . . . . . . . . 621
Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649
9. . . . . . . . . . . . . . . . . . . . . 651
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
, . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684
10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750
A. Microsoft MSXML3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751
B. Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808
C. Saxon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828
D. Xalan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 860
E. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
F. TrAX: API XML . . . . . . . . . . . . . . . . . 913
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 950
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 966
Software AG,
XML,
Tamino. Software AG
W3C XSL.
ICL.
( Ph.D., )
,
,
. XML XSLT
Saxon
XSLT.
, , . ,
, .
, W3C
XSL, XSLT. ,
. , ,
,
, ,
.
, XSLT
XPath, .
, XSLT,
XSL, , ,
, .
,
.
ICL Software AG, ,
.
Wrox Press
, ,
.
, ,
,
, .
, XML
, ,
.
. XML ,
,
.
, XML,
, ( DOM SAX),
.
, , SQL,
(
);
XSL (XSL Transformation), XSLT, , SQL
: ,
XML
,
, .
1998 XML
Java
Saxon,
XML. XSL,
Saxon, XSLT
. 16 1999 , , XSLT
1.0, 17 ,
.
XSLT, ,
,
. SQL:
, SQL ,
,
, .
12
. XSLT
, , .
XSLT,
W3C ,
, .
,
.
?
,
XSLT . ,
XML, , ,
, , ,
, .
HTML.
, ,
.
HTML Javascript,
.
?
, XSLT
, , ,
, .
MSXML3 Microsoft ,
;
. Microsoft
; XSLT
, .
XSLT 1.1. ,
.
, XSLT
XSLT 1.0 ,
. (
),
; , .
(Steve Muench) key()
, , .
13
?
( 1 10) XSLT (
XPath) , .
(
), XSLT .
, :
MSXML3 Microsoft, XDK Oracle, Saxon Xalan,
, , , 4XSLT Uni
corn. XSLT ,
( ),
;
, , ,
MSXML3 .
XSL,
Microsoft Internet Explorer 5 1998 (
WDxsl1). XSLT
,
.
WDxsl ,
Microsoft W3C
XSLT 1.0, WDxsl .
?
.
13.
XSLT. 1 ,
, ,
XSLT?. 2
,
XSLT.
3 ,
,
.
, 48, .
,
,
, .
1
WD Working Draft
. ,
, , Microsoft ,
XSL, .
1. . .
14
,
: XSLT 4,
XPath 5, 6,
7. , 8
XSLT 1.1 (
) XSLT ,
Java JavaScript.
, .
, 9 10,
XSLT . 9
, 10
.
,
. MSXML3 Microsoft, Oracle, Saxon
Xalan , API,
,
. E
, XSLT
(4XSLT, Infoteria, Sablotron, Transformiix Unicorn),
XSLT, Stylus Studio, Whitehill's
XSL Composer XML Spy.
,
,
.
F .
TrAX API, Java API XSLT
.
, ,
( API Sun
Saxon XalanJava).
.
XSLT
,
,
.
, XSLT, ,
1:
1
xmlhack.ru,
XML XSLT.
. . .
15
http://www.w3.org/Style/XSL/
World Wide Web.
,
, .
http://www.xslinfo.com/
, (James
Tauber)
XSL, , .
http://www.oasisopen.org/cover/xsl.html
(Robin Cover)
, SGML
XML. XSL.
http://www.xml.com/
,
XML .
http://msdn.microsoft.com/xml/
URL Micro
soft XML XSL.
,
.
http://www.mulberrytech.com/xsl/xsllist
XSL, ,
XSLT,
.
,
FAQ .
?
;
.
, , ,
.
http://
www.wrox.com, .
XSLT, ,
, .
(freeware), .
16
Microsoft MSXML3.
http://msdn.microsoft.com/xml, A
. MSXML3 XSLT
Internet Explorer.
XSLT 1.0.
: .
Windows :
Instant Saxon, :
http://users.iclway.co.uk/mhkay/saxon/instant.html
Programmer's File Editor (PFE),
, :
http://www.simtel.net/pub/simtelnet/win95/editor/pfe101i.zip
Instant Saxon ,
. Saxon ,
,
. , ,
Saxon.
MSXML3, Xalan Oracle XSL, ,
100 , .
Java , Saxon
XML
. ,
Windows, . PFE
, ,
,
Windows . .
PFE.
Windows , Java
. Java
Java .
.
,
:
17
XML,
. example.xml,
Wrox1 http://www.wrox.com/,
, , .
<source data=xml/>
XSLT,
.
style.xsl,
Wrox.
<xsl:stylesheet...
XML, HTML
.
<html>...</html>
:
<data>
XML XSLT
</data>
:
: .
: dummy.xml.
: File/Save as.
, : a=3;.
,
,
, ; ,
1
, ,
. . .
.
18
:
, .
,
.
( 5
6) ,
W3C,
. ,
, :
clause|paragraph
!|?
, .
, ,
, :
.
adjective noun .
adjective, noun, .
adjective? noun
adjective* noun
adjective, noun.
adjective+ noun
adjective, noun.
sentence (?|!)
sentence,
. .
Wrox .
:
www.wrox.com.
p2p.wrox.com.
Wrox.
19
www.wrox.com ,
, ,
.
p2p.wrox.com, ,
. XSLT
'XML'.
.
, ,
.
.
, , .
, .
, , ,
Lyris
,
.
, ,
support@wrox.com.
:
Subject , ISBN
.
,
.
Wrox ,
, .
, ,
, . Wrox
, .
. , ,
: feedback@wrox.com.
1
XSLT
XSLT.
XSLT , . ,
XSLT,
,
. ,
XSLT : , 2 3.
, XSLT,
, XML.
, .
XSLT
XML,
, .
, XSLT,
, .
,
, .
, , , XSLT
.
XSLT
,
, .
XSLT?
XSLT, eXtensible Stylesheet Language: Transformations (
: ), , ,
XSLT?
21
( http:/
/www.w3.org/TR/xslt), , ,
XML . XSLT
XML HTML ,
:
XSLT XML.
? ,
, XML .
XML?
XML ,
.
, XML
,
XML
. XML
:
.
(, )
.
, . ,
,
( ),
, ,
.
.
( ) ,
.
, ,
, .
, XML
.
,
,
. XML
,
, ,
. , XML,
,
, :
.
22
1. XSLT
,
, : HTML,
PDF . XML
HTML , XSLT
,
. HTML,
.
, , ,
.
: , SQL, HTTP
. XML, ,
.
XML XSLT
. , XML
, .
. ,
, ,
, . ,
,
.
XML XML
, XSLT .
XSLT XML.
XML.
XSLT ,
, , ,
XSLT XML.
:
http://www.xml.org/xmlorg_registry/index.shtml
XML.
XML
. : ,
,
, ,
. , MusicML
; ChordML
( ) ; Mu
sicXML ,
XVII ,
MML (Music Markup Language),
23
XSLT?
(University of Pretoria),
, ,
(. 1.1).
. 1.1.
, XSLT
:
XSLT
, MusicXML MML.
XSLT
,
XML SVG.
XSLT ,
MIDI (Musical Instrument Digital Interface,
).
XSLT , ,
.
XSLT HTML
XML.
, XSLT XML
HTML!
24
1. XSLT
XSLT XML?
, , XSLT
XML .
:
,
XML ,
.
,
, HTML PDF.
, .
, ,
HTML, XML. HTML
.
,
, ,
, XML. ,
XML
, XML. ,
XML,
: XSLT
,
XML SVG.
XSLT
VoxML .
VoxML (Voice Markup Language)
Motorola http://www.oasisopen.org/cover/
voxML.html.
, , ,
, , XSLT
.
, ,
,
.
, ? XSLT XML
.
XML,
(API, Application Programming Interface)
XML,
. API: SAX (Simple API for
XSLT XML?
25
XSLT XML
, ? XSLT
, ,
, ,
, ,
C++, Visual Basic Java.
. ,
,
. XSLT
, ,
. XSLT
,
XSLT.
XSLT XML ,
, DOM SAX, XML
. XSLT
XML, . ,
DOM, XML (
, , . .)
. XSLT ,
,
.
XSLT DOM , . ,
XSLT, 2.
1
. . XML . .: , 2001.
26
1. XSLT
XSLT ( ,
,
)
, SQL. .
XSLT SQL:
XSLT .
.
.
, ,
, SQL. , XML .
,
.
,
, , ,
XML XSLT.
SQL XSLT . ,
. ,
XML
,
. SQL SELECT. XSLT
XPath.
XPath XSLT, ,
W3C (http://www.w3.org/
TR/XPath), XSLT (
XPath XSLT XSLT
XPath).
XPath
XML XML ,
.
, . XSLT
(
, . .).
XSLT SQL :
,
.
,
. ,
,
.
XSLT XML?
27
,
, , ,
. SQL , XSLT ,
XML.
, , ,
, ,
:
. SQL
, ; XSLT
(
XSLT 1.1, )
.
XSLT SQL, , .
,
XML. ,
, .
, XSLT,
.
, XML SQL,
.
Microsoft SQL Server 2000 Oracle 9i.
XSLT
, XSLT,
.
XSLT
XSLT XSLT
XML . ,
XML,
. , XSLT
.
XSLT, .
: Saxon, Xalan Microsoft MSXML3.
(
).
,
.
Saxon XSLT ,
. Java
, .
28
1. XSLT
XSLT XML?
29
SDK
. , xm
linst.exe. , MSXML3
XML Internet Explorer ( ,
IE5 WDxsl).
XSLT
Microsoft.1
, .
, ,
, .
. :
http://www.w3.org/Style/XSL
http://www.xslinfo.com/
http://www.xml.com/
http://www.oasisopen.org/cover
XSLT
XML.
30
1. XSLT
. 1.2.
.
XSLT ,
DOM. XML
1 .
, XML
<?xmlstylesheet?>. XSLT
,
. href URI
.
HTML,
"Todays greeting"
, XML:
<html>
<head>
<title>Todays greeting</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
XSLT
hello.xsl, :
<?xml version="1.0" encoding="iso88591"?>
1
. xml
, .
, ,
SAX DOM, . . . .
XSLT XML?
31
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Todays greeting</title>
</head>
<body>
<p><xsl:valueof select="greeting"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
, .
Saxon
Saxon ( Windows):
Instant Saxon
saxon.exe
Notepad,
: hello.xml hello.xsl (
Wrox http://www.wrox.com)
MS DOS ( | | MS DOS Windows 98,
Windows NT 2000)
:
saxon hello.xml hello.xsl
HTML, .
HTML:
saxon hello.xml hello.xsl > hello.html
XML
, :
saxon a hello.xml > hello.html
XalanJava
XalanJava
. Saxon, Xa
32
1. XSLT
lan Windows,
Java ( Sa
xon ).
Java. Xalan
Microsoft, In
ternet Explorer (
Java), .
JDK 1.3, Sun,
http://java.sun.com/j2se/1.3/. ,
.
XalanJava 2 .zip,
. ,
Java. xalan.jar (
XSLT) xerces.jar (
XML), bin. Java VM
,
CLASSPATH. auto
exec.bat ,
; Windows NT Windows 2000
(System Control Panel). ,
, XSLT.
.jar, c:\jars,
CLASSPATH :
SET CLASSPATH=.;c:\jars\xalan.jar;c:\jars\xerces.jar
, CLASSPATH
.jar, , .
"hello world" Xalan
:
java org.apache.xalan.xslt.Process in hello.xml xsl hello.xsl
, Saxon.
:
java org.apache.xalan.xslt.Process in hello.xml
out.
MSXML3
, Internet
Explorer.
MSXML3 XSLT
,
XSLT XML?
33
XML. ,
XSLT XML.
.
iso88591 ( , Micro
soft ANSI),
. ,
, UTF8.
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
XSLT. XML
, ,
. xmlns:xsl XML ,
, , XSLT
W3C, xsl. XSLT
XML, ,
, ,
, . version
, 1.0
XSLT.
:
<xsl:template match="/">
<xsl:template> ,
. match="/" ,
. /
XPath, : XML
34
1. XSLT
, UNIX, /
, XPath /
XML. DOM
Document, XPath
.
<html>
<head>
<title>Todays greeting</title>
</head>
<body>
<p><xsl:valueof select="greeting"/></p>
</body>
</html>
,
, .
, , HTML
, .
<xsl:valueof>, XSLT,
xsl.
. select ,
. XPath "greeting" :
<greeting>, ,
.
greeting. <xsl:valueof>
, , <p>.
, :
</xsl:template>
</xsl:stylesheet>
,
, .
, <xsl:template> .
, :
<html xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<head>
<title>Todays greeting</title>
</head>
<body>
<p><xsl:valueof select="greeting"/></p>
</body>
</html>
XSLT XML
35
XSLT ,
,
HTML (
<xsl:valueof>) .
, , XSLT .
XML
?
: ,
. ,
.
:
? . ,
Saxon Xalan ,
, .
XSLT Microsoft,
HTML,
.
<?xmlstylesheet?> .
XSLT
XPath, XML.
XSLT XML
XSLT World Wide Web (W3C)
XML,
W3C. XSLT,
, .
XSLT XSL
XSLT XSL (Extensib
le Stylesheet Language, ).
, XSL ( )
XML ,
. XSL , ,
, :
, , ,
,
. , ,
XSL : ,
XSLT,
XSL,
XSL, XSLFO (XSL Formatting Objects).
36
1. XSLT
XSL XML,
. XML, XSLT
. XSL
. (
XSLT),
,
, , . ,
, XSLT. XSL
. ,
HTML ,
,
XSLT , , XSLT
CSS CSS2 (Cascading Style Sheets),
.
XSL,
(Candidate Recommendation),
http://www.w3.org/TR/xsl.
, W3C
,
. XSL
,
.
XSLT XPath
XSLT
XSLT XPoin
ter, .
, ,
,
XPath, . 1.0 XPath
XSLT, 16 1999 .
XPath
XSLT. XPath ,
,
( )
, . ,
:
<xsl:valueof select="sum(//book/@price) div count(//book)"/>
XSLT XML
37
<xsl:valueof> ,
XSLT,
. select XPath,
: price <book>,
<book>.
XPath
, XSLT. , DOM (
Microsoft)
DOM, selectNodes (XPath), ,
, DOM3.
, XPath W3C,
XPointer XQuery.
XPath XSLT ,
,
, . ,
XPath ,
XSLT. :
XPath , ,
. , ,
stringlength(), XPath,
,
XSLT, key(), XSLT.
,
XSLT+XPath . , ,
7. ,
, ,
, ,
,
.
, XPath ,
, selectNodes() DOM,
7, ,
XPath XSLT.
38
1. XSLT
,
W3C. ,
.
.
, , ,
,
.
XSL, Microsoft IE5
WDxsl,
. , ,
Microsoft XSL,
, XSLT,
.
WDxsl Wrox Press XML IE5 Prog
rammer's Reference ( XML IE5), ISBN 1861001576.
,
,
XSLT, .
. . .
XSLT XML
39
A XML Microsoft,
, .
XSLT XML
, XSLT XML.
, ,
.
XML , XSLT:
XML XML (XML Informa
tion Set). .
XML
XSLT , XML (XML na
mespaces) XML. ,
XSLT XML, , XML
, XML Namespaces,
http://www.w3.org/TR/RECXMLnames.
XML 7
Wrox Press Professional XML (XML ), ISBN 1861003110.
XSLT.
XML
. ,
<table> ,
<table>
. :
URI (Uniform Resource Identifier).
. URL,
http://www.wrox.com/namespace. ,
, XML (.,
, http://www.biztalk.org) URN, urn:java:com.icl.saxon.
URI , URI,
.
URL .
,
, URL . URI
,
, URI ;
.
URI
/,
. ,
, ,
40
1. XSLT
. ,
,
URI
( , ). ,
xsl, URI
http://www.w3.org/1999/XSL/Transform,
xslt;
.
, .
.
:
xmlns:prefix = "namespaceURI"
,
,
, .
, ,
( ),
:
xmlns = "namespaceURI"
XSLT XML,
XML Namespaces. ,
XML Namespaces
XML, .
. ,
DTD (Document Type Definitions), DTD
. ,
XSLT DTD,
, DTD.
XML (XML Schemas).
XML
XSLT ,
XML, . ,
XSLT
, ,
. , ,
,
, , .
,
,
XSLT XML
41
XML,
. .
XML XML
(XML Information Set definition), "infoset".
http://www.w3.org/TR/xmlinfoset.
, ,
.
, ;
,
. 2 , XSLT
( XPath) XML
,
DOM.
(PSVI, postschemavali
dation infoset).
, XML.
(, 17.3), ,
.
XSLT ,
, XSLT 2.0.
XSL CSS
: XSL (
XSLT XSLFO) CSS CSS2 (Cascading
Style Sheets)?
,
, ,
,
CSS XSL
.
CSS ( CSS2,
), ,
HTML,
XML,
XML. .
,
, ,
, , ,
. ,
,
.
42
1. XSLT
, CSS
. ,
,
, ,
. ,
HTML,
. CSS, XSLT
, ,
, .
.
XSLT ,
, ,
CSS, :
. ( ) XSLT
, CSS ( ),
,
, ,
,
.
XSL
XML, XSLT
World Wide Web (W3C)
, (Tim BernersLee),
WWW. XSL,
http://www.w3.org/Style/History/.
(BernersLee) HTML
: , ,
, , . .
,
,
. HTML
, :
, , , .
, ,
.
.
;
SGML (Standard Generalized Markup Language,
),
XSL
43
( )
ODA (Open Document Architectu
re), ISO.
XML
SGML, XSLT SGML
DSSSL (Document Style Semantics and Spe
cification Language, ). DSSSL
( Dissel) , ,
,
,
SGML, . DSSSL
1990 ,
SGML,
,
,
.
WWW'94 .. (C.M. Sper
bergMcQueen) . (Robert F. Goldstein)
SGML (A Manifesto for Adding SGML Intelligence to the WorldWide
Web). http://www.ncsa.uiuc.edu/
SDG/IT94/Proceedings/Autools/sperbergmcqueen/sperberg.html.
,
,
XSL. ,
,
.
, (fall
back processing), ,
.
:
, ,
SGML.
: ,
.
: display
, inline.
:
, .
,
:
.
:
,
44
1. XSLT
(, )
;
,
.
DTD.
,
. :
SGML DTD, ,
SGML. SGML,
.
DSSSL.
DSSSL
. , DSSSL ,
, ,
DSSSL,
, .
,
.
, DSSSL
WWW .
1995
W3C .
(James Clark) XSLT,
,
DSSSL. http://www.w3.org/Style/
951106_Workshop/report1.html#clark.
:
DSSSL , .
,
( ).
, ,
.
, ,
, ,
. DSSSL,
, (,
DSSSL).
, ,
Scheme.
.
DSSSL , SGML
(flow object tree).
('' CSS):
, ,
.
XSL
45
:
, !
, XSLT
.
XSL
, W3C
.
DSSSL.
XSL,
21 1997 . http://
www.w3.org/TR/NOTEXSL.html.
.
Microsoft, Inso Corporation, , (Paul Grosso)
ArborText, ( )
(Henry Thompson) .
, :
XSL , .
, CSS (,
). , CSS
XML, XSL ,
,
XML XML, .
:
:
:
:
XSL ,
.
.
, HTML/JavaScript.
, XSL, :
/,
,
,
46
1. XSLT
,
DSSSL
CSS .
:
XSL .
XSL XML.
XSL ,
.
XSL
, .
CSS
XSL.
XSL FOSI.
XSL .
XSL .
XSL .
XSL .
XSL .
.
, ,
, , .
, , ,
, ,
. , ,
XSLT , ,
.
, ,
XSLT ,
. , ,
,
, ,
.
,
9. , ,
,
,
( ,
),
,
XSL
47
. , XSLT
, .
1998 , ,
Microsoft .
W3C ,
(Norman Walsh) ,
1998 . http://www.w3.org/TR/WDXSLReq.
, , ,
, ,
, .
XSLT ,
.
, ,
,
, , ,
, ,
:
, , , ,
, , , ,
.
, ,
, , , .
: , ,
(Flow Objects), XML.
: .
:
, XSL. .
, : ;
, .
18 1998
(Working Draft) XSL ( ),
,
, 16 1999 ,
.
,
.
XSLT 1.0
,
, XSLT 1.1 12 2000 .
XSLT 1.1,
; ,
XSLT 1.1, ,
48
1. XSLT
.
, XSLT 1.0
, .
XSLT .
XSLT
XSLT ,
?
: , XML, ,
, , , ,
.
XML
, SGML
1994 , ,
. , ,
:
<xsl:variable name="y">
<xsl:calltemplate name="f">
<xsl:withparam name="x"/>
</xsl:calltemplate>
</xsl:variable>
, y = f(x);,
, .
:
, XPath,
XML, select="//"
:
<select>
<path>
<element type="">
<element type="">
<element type="">
</path>
</select>
XSLT
XML , , :
XML,
,
.
XSLT
49
HTML/
XML CSS , .
DSSSL
; , .
( ASP JSP
)
, .
,
Unicode, ,
, .
,
( , ,
XSL Microsoft), ,
.
. (
,
E.)
, , XML,
, ,
. , , ,
.
, XSL ,
,
, , ,
, : ?
,
, ;
, ,
,
,
. ,
. ,
( ),
. ,
, ; ,
, ,
, ,
, .
9.
50
1. XSLT
,
, ,
, (progressive
rendering). ,
XML ,
. , XML
, ,
,
. ,
,
.
, ,
.
XSLT .
, , ,
,
. ,
XSLT ,
. .
. . (E. F. Codd) 1970
, , ,
,
, .
, (,
, ) ,
.
, ,
.
, ,
,
; ,
.
,
.
,
: XalanJava 2, ,
, ,
;
MSXML3 ( API), ,
. Stylus Studio, E,
, ,
.
XSLT
51
,
. ,
.
, , ,
,
.
!
9.
XSLT , , ,
, ,
,
.
XSLT ,
, ,
. ;
. ,
. XSLT :
,
, ,
, .
, , CSS.
XSLT , (,
), (, ,
)
.
:
, ,
, .
,
, , , , .
XML.
poem.xml, poem.xsl.
<>
<>Rupert Brooke</>
52
1. XSLT
<>1912</>
<>Song</>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
<>
<>My heart all Winter lay so numb,</>
<>The earth so dead and frore,</>
<>That I never thought the Spring would come again</>
<>Or my heart wake any more.</>
</>
<>
<>But Winter's broken and earth has woken,</>
<>And the small birds cry again;</>
<>And the hawthorn hedge puts forth its buds,</>
<>And my heart puts forth its pain.</>
</>
</>
,
, . 1.3.
. 1.3.
XSLT
53
:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
. <>
HTML,
( ,
). <xsl:valueof>
. <xsl:apply
templates>
.
<xsl:template match="">
<html>
<head>
<title><xsl:valueof select=""/></title>
</head>
<body>
<xsl:applytemplates select=""/>
<xsl:applytemplates select=""/>
<xsl:applytemplates select=""/>
<xsl:applytemplates select=""/>
</body>
</html>
</xsl:template>
<>
HTML,
:
<xsl:template match="">
54
1. XSLT
<p><xsl:applytemplates select=""/></p>
</xsl:template>
<> .
,
( ). <xsl:if>
, position(),
.
, HTML <br>,
.
<xsl:template match="">
<xsl:if test="position() mod 2 = 0">  </xsl:if>
<xsl:valueof select="."/><br/>
</xsl:template>
<xsl:stylesheet>:
</xsl:stylesheet>
XSLT,
, ,
. 9
XSLT,
. , Hello World,
, :
, (fillintheblanks),
, ,
, , ,
.
XSLT 1.0
, XSLT 1.0, ?
XSLT 1.0 XSL,
,
: XSLT 1.1
,
, XSLT 2.0
, .
XSLT 1.1
XSLT 1.1 12 2000 .
XSLT 1.0:
XSLT 1.0
55
: <xsl:document>,
, Saxon,
, xt, Xalan Oracle.
. ( .)
: ,
.
nodeset(), xt
.
, Java
ECMAScript. XSLT 1.0
, ,
, Xalan, XSLT
xt Saxon . XSLT 1.1
, ,
Java ECMAScript (
JavaScript).
xml:base,
XML, XML URI
(URI ),
URI, .
XSLT 1.1 ,
.
XSLT 2.0 XSLT 1.1,
XSLT 2.0. ,
, XSLT 1.0
, ,
.
, XSLT 1.1.
,
XSLT 1.1
2001
, . , XSLT 1.1
, ,
, W3C
.
, W3C
XSLT 1.1 ,
XSLT 2.
XSLT 1.1
, 12 2000 .
56
1. XSLT
,
: ,
,
,
, XML.
, XML Qu
ery. XQuery SQL ,
, ,
XML XML.
15 2001 (. http://
www.w3.org/TR/2001/WDxquery20010215/),
, Quilt
(Don Chamberlin), (Jonathan
Robie) (Daniela Florescu). XQuery
,
XSLT XPath. W3C
,
XQuery ,
XPath, .
,
, XML Query
, ,
, .
,
XML Schema. XML Schema W3C
(20 2000
),
. XML Schema DTD,
, . ,
XSLT
57
,
(),
.
XPath (
) ,
, ,
XPath 2.0 .
XSLT
,
XSLT,
.
XSLT .
, ,
, XSLT:
,
.
XML. , ,
, ,
XML,
, ,
,
( ,
XML
). XML,
,
EDI ( ) .
XML (. 1.4)
XSLT .
. 1.4. XML
58
1. XSLT
,
, . .
.
XSLT ,
: ,
(, ,
) , , Java
Script Perl, .
,
, , Java JavaScript.
XSLT XML
(. 1.5),
EDI. , ,
XML , .
, , XSLT
XML (. 1.6)
:
. 1.5. XML
. 1.6.
XML
,
; . ,
. ,
,
. 10
,
, XML,
. ,
XML ,
XSLT:
XML,
XML: SAX DOM.
XSLT ,
SAX DOM, XML.
:
XSLT
.
XSLT
59
,
XSLT .
, .
,
. , ,
XSLT .
, ,
.
,
, , SAX.
, ,
XSLT, , ,
. SAX,
,
XSLT
.
,
,
( ) .
, .
,
. XML ,
,
, SGML.
XML ,
,
, XML
. :
, ,
, XML.
XML , .
, XSLT
,
, , XML.
60
1. XSLT
.
.
XSL (XSL Formatting Objects) XML
. ,
, , ,
.
, HTML
. HTML , , XML, ,
. XML
HTML XSLT.
. XML ,
HTML,
HTML, XML.
XHTML 1.0, , ,
XML. ,
XHTML.
?
.
. 1.7.
XSLT
61
, XSLT
:
,
, XML
.
XML, ,
XML
. ,
.
XML HTML ,
.
, Java Java (Java
Server Pages). Microsoft
XSL ISAPI, http://msdn.microsoft.com/xml, ,
,
ASP.
XML HTML
.
, , ,
.
XML
HTML
. ,
, ,
.
,
.
, XSLT
, , . ,
, XML
.
,
,
.
HTML ,
HTML.
62
1. XSLT
XSLT.
:
?
XML?
?
?
, XSLT
, XML,
:
XSLT
, ,
. ,
, XSLT , .
, ,
. ,
,
,
.
2
XSLT
XSLT.
: .
,
XML . ,
XSLT XML ,
,
.
, ,
,
. XSLT :
, , ,
. 1,
, ,
XSLT.
, ,
XSLT ,
.
XSLT:
, XSLT.
XSLT ,
.
(. 2.1):
64
2. XSLT
. 2.1.
, ,
XML. XSLT
, ( )
( ) .
: ,
, ,
, .
.
,
:
. XML
, , .
,
,
. ,
, XSLT, :
,
,
, ,
.
,
,
XML . HTML
( ),
XSLT:
65
, XML.
,
, LDAP, EDI, ,
, .
, XML,
,
.
XSLT
XML, .
. API
; ,
, .
DOM W3C, ,
DOM API.
DOM.
,
XPath, ,
. ,
, ,
.
XSLT
.
. 2.2. ,
66
2. XSLT
, XSLT
.
.
, , :
XML (
) XML (
). ,
, , .
, XML.
XSLT,
, XSLT .
,
, .
<xsl:output>,
4 .
<xsl:output> ,
: xml, html text.
.
xml XML.
, XML
, XML. <xsl:output>
XML, ,
CDATA.
html HTML,
HTML 4.0, .
HTML XSLT
HTML . ,
, <hr>, ,
,
<script>. ,
( )
é.
text ,
. ,
,
RTF PDF (Adobe)
, SQL
JavaScript. .
XSLT:
67
XHTML , XHTML
, , XML, xml
, XML.
<xsl:output> ,
, HTML, <html>,
XML.
,
.
:
. ,
ContentHandler, SAX2 API,
http://www.megginson.com/,
DocumentHandler, SAX1,
Wrox Press Professional XML (XML ).
, XSLT
,
( 16 ),
. ,
(
, ,
COM Java,
COM Java). XSLT
, .
. 2.3.
( )
68
2. XSLT
,
.
:
, .
document() ( 7
),
, URI
. , ,
, .
.
.
, <xsl:include> <xsl:import>,
.
, :
,
.
3.
XSLT
.
: ,
,
HTML ,
. , <xsl:document>,
4,
XSLT 1.1, ,
, , XSLT 1.0.
, XSLT,
. XPath,
XSLT;
.
XSLT
XML (DOM).
. .
XML
XML
.
69
: XML
:
<>
<></>
<></>
<> .</>
<>
<></>
<>
<>
<>ex</>
<></>
</>
<>
<>portare</>
<></>
</>
</>
</>
</>
,
,
(. 2.4).
. 2.4. ( )
70
2. XSLT
, (
3).
,
: , ,
.
*:
.
,
XML,
, .
(root).
, Document DOM:
, .
,
, .
.
, XPath
XSLT . XPath
, .
XSLT
XML, ,
, XML. ,
XML ,
;
( XML , XSLT
) ( )
,
.
XSLT ;
,
,
. , .
XML
, XML
.
. XSLT,
XML
(http://www.w3.org/TR/xmlfragment).
XML ,
.
71
: XML
XML,
, ,
, :
<></> <></>
<></>.
XPath.
, :
. 2.5. XPath ,
XML
:
.
,
, ,
.
XPath , .
XML
:
;
. XPath
, Document DOM.
,
,
.
72
2. XSLT
,
: </>.
PCDATA .
, :
,
. DOM ,
.
,
(
). , ,
DTD,
.
(,
xmlns xmlns:)
.
,
XML <!
>.
, XML
<? ?>.
XML,
. , XML <?xml
version="1.0"?>
, .
, , ,
. ,
, .
, ,
,
,
.
.
,
( ); , (, ); ,
(, ,
), ,
(, , ,
).
, XSLT ,
73
.
,
. ,
UML, , .
UML (Unified Modeling Language)
. UML
http://www.omg.org/technology/uml/index.htm
(PierreAlain Muller) Instant UML ( UML), Wrox Press, ISBN 1861000871.
. 2.6. UML
, ,
, :
,
:
.
,
.
.
, .
.
,
. (, DOM,
#comment.)
74
2. XSLT
XML, .
XML,
.
,
( xmlns:).
, xmlns:acme="http://acme.com/xml"
acme,
xmlns="http://acme.com/xml"
, .
, , , XML
(QName, qualified na
me). : ,
: XML, ,
:. ,
. , xsl:stylesheet
xsl stylesheet.
, ,
. ,
. URI
. URI ,
, ,
:. , ,
xsl:stylesheet, URI http://www.w3.org/1999/XSL/
Transform ( ,
) stylesheet.
,
. ,
URI ,
, .
,
, , name(),
7,
XML.
, .
, ,
, . ,
. ,
URI .
75
,
Unicode.
, ,
XML, #xD #xA
XML #xA.
.
,
, ,
.
.
. : PCDATA,
( )
. ( DOM, nodeValue
.)
,
, URI .
URI
URI. URI
. URI URI ,
XML, , , URI ,
,
XML. URI
URI,
, , href
URI , .
XSLT 1.1 , URI
xml:base. , xml:base="../
index.xml", URI ,
XML,
index.xml , ,
URI .
URI
. , URI
, URI . URI
.
URI
. . ,
URI , URI
76
2. XSLT
URI , .
, URI
URI. W3C ,
URI
, ,
XSL .
URI,
, ; ,
, .
URI :
URI
document(), 7.
( )
. ,
, .
,
.
,
, ,
, ,
.
, ,
,
.
, .
;
.
, , .
:
,
. , ,
: , ,
, , .
. :
77
.
, ,
, .
, .
:
. ,
; ,
, , .
,
.
,
. ,
.
UML
UML.
:
, ,
( ), , .
:
.
.
.
DTD ,
unparsedentityuri().
: URI,
URI ,
, ID, ID
, (. 2.7).
, XSLT
null , SQL Java.
,
.
, ,
.
78
2. XSLT
. 2.7. UML
.
.
.
XSLT XPath
XML Namespaces,
, XML Namespaces .
http://www.w3.org/TR/RECxmlnames.
, XSLT XML 1,
, :
79
URI .
, URI
.
:
, .
URI,
, http://www.mydomain.com/namespace/
billing. XSLT URI,
URI ,
:
URI, http://. ,
URI, billing.dtd.
W3C ,
URI
XML ,
. ,
. XSLT
, URI
. , abc, 42 ?!*
URI . ,
URI ,
Unicode.
URI
, URL,
, ,
. : c:\this.dtd C:\THIS.DTD
URI , ,
;
, ,
.
, URI
http://www.w3.org/1999/XSL/Transform, ,
, .
, ,
.
. "myprefix" URI
http://my.com/namespace:
<a xmlns:myprefix="http://my.com/namespace">
. .
URI http://your.com/namespace :
<a xmlns="http://your.com/namespace">
80
2. XSLT
,
, ,
, URI.
, .
URI
.
: , URI
. ,
prefix:localpart; , xsl:template xsl,
template. URI
,
, . (
,
, .)
XML Namespaces ,
: .
XSLT ,
XML, ,
, .
.
, URI
URI
, URI
(, XSLT ).
XPath URI
, ,
.
,
URI .
URI
. ,
; ,
.
TrAX, F,
{namespace.uri}localname.
, ,
; ,
.
XPath
:
, ,
(, URI )
81
,
. ,
. , ,
,
.
,
: , na
me(), .
XML,
.
xmlns:*,
.
(ID) ,
. ,
( ) ,
.
, DTD ID.
,
( ) .
, XML, ,
<>
. :
<>
< ="123456789123">1
<> </>
...
</>
< ="123456789124">
<> </>
82
2. XSLT
...
</>
</>
, DTD ID
:
<!ATTLIST ID #REQUIRED>
ID ,
; , , ID
. ; ID ,
DTD ID, .
XML.
, ,
/ .
XML IDREF
IDREFS, ,
( IDREF ,
IDREFS , ).
XPath . XPath
id() (. 7),
, .
, IDREF
IDREFS, .
IDREF IDREFS .
,
XPath XML
. XML ( ),
XML,
,
XML. XPath,
, ,
, . ,
,
, , id()
, , , .
, ,
XML, .
ID, ,
DTD, XPath.
, , . , ID
,
. ,
DTD.
XSLT
( ) , .
83
, ,
.
<xsl:key> (. 4, xsl:key),
key() (. 7, key).
: #x9,
#xA, #xD #x20.
, #xA,
, XML.
,
. , XPath
:
>
>
84
2. XSLT
>
>
>
<![CDATA[>]]>
XML .
XSLT
XML, XSLT ,
, .
. XML
XML XSLT
, 3.
(
)
: (disableoutput
escaping). <xsl:text> <xsl:val
ueof>
, disableoutputescaping="yes";
, , (&),
&, &, .
, ,
<xsl:copy>
<xsl:copyof>, . (
,
, .
,
,
, , .)
?
,
. XML
, ? ,
, CDATA?
? ?
XSLT :
,
? : ,  ?,
: , ,
,
XPath.
85
, XML :
, . ,
;
, .
XML .
, , ,
, . , (,
), .
, CRLF LF ,
: ,
.
XML
, XSLT XPath.
,
. ,
, .
, XML,
, XML,
,
,
.
, W3C ,
XML,
XML (XML Information Set), InfoSet,
. http://
www.w3.org/TR/xmlinfoset.
2 2001 ;
,
.
XML
, .
Infoset
, , ,
. , ,
,
.
:
: , , ,
, , , ,
.
: ,
, , ,
86
2. XSLT
, ,
, CDATA, CDATA.
XML :
,
.
,
.
, (,
).
, ,
:
, Infoset, , .
. ,
, , ,
,
.
XML
XML (http://www.w3.org/
TR/xmlc14n).
: ,
XML
. ,
XML,
; ,
.
:
UTF8.
#xA.
CDATA .
XML .
(<a/>) (<a></a>).
.
87
, DTD ,
.
.
:
.
, Infoset
XML,
,
.
(. 2.8)
: ,
; , Info
set, XML;
. 2.8.
88
2. XSLT
XML,
.
,
XSLT/XPath XSLT,
,
:
XSLT ,
XML.
, XSLT
. , SAX1 XML
. , SAX2.
XML ,
.
XSLT ,
, , name() XPath
,
URI .
XSLT URI ,
XML.
XPath Infoset
: Infoset
, XPath
.
. ,
. , Infoset
, ,
CDATA
.
XML, XPath.
, ,
( ). ,
, ,
XML
. :
CDATA
XML
standalone XML
DOCTYPE
89
,
.
(
, ) , ,
. ,
, ,
<a/> <a></a> ,
.
, ,
,
XML,
, . ,
, W3C
.
, ,
, ,
XML.
, ,
.
,
:
<item/>
<item></item>
>
>
<e>"</e>
<e>"</e>
a < b
<a xmlns="one.uri"><b/></a>
, CDATA,
. , ,
.
CDATA? , , ,
, , XML,
. , XML
90
2. XSLT
, XML .
,
CDATA: , ,
<![CDATA[ ]]> , XML
.
DTD
XPath DTD
. , XML, ,
, DTD
XML,
.
XSLT ( ) ,
ID, id()
. ,
, ,
.
, , XSLT,
. ,
, . .
.
1,
.
<xsl:template> match. match
. ,
.
, / ; title
<title>, chapter/title
<title>, <chapter>.
XSLT ,
, ,
.
.
, .
,
91
, (.
).
, ,
. XSLT .
<xsl:template>
.
,
, ,
<xsl:text> xml:space.
. XSLT ,
, .
, .
. ,
, ,
. , ,
.
:
<xsl:template match="/">
<xsl:message>!</xsl:message>
<xsl:comment> XSLT</xsl:comment>
<html>
. . .
</html>
</xsl:template>
(<xsl:message> <xsl:com
ment>), ( <html>)
(). ,
,
(
, ) .
,
, . ,
XSLT ,
. ,
(
<xsl:comment>), <html> (
<html>) .
92
2. XSLT
<xsl:message> , ,
XSLT .
<xsl:message>, ,
, .
<html> ...,
.
<html>, ,
. ,
.
, :
<xsl:template match="/">
<xsl:message>!</xsl:message>
<xsl:comment> XSLT</xsl:comment>
<html>
<head>
<title> HTML</title>
</head>
<body>
<xsl:applytemplates/>
</body>
</html>
</xsl:template>
93
,
.
.
,
<xsl:applytemplates/>; ,
.
,
.
, <xsl:applytemplates/> .
,
,
,
, <xsl:applytemplates>
.
:
, .
, .xml :
<?xml version="1.0"?>
<>
< ="">
<> </>
<> </>
<>8.95</>
</>
< ="">
<> </>
<> </>
<>12.99</>
</>
< ="">
<> </>
<> </>
<>8.99</>
</>
< ="">
<>. . . </>
<> </>
<>22.99</>
</>
</>
94
2. XSLT
,
. ,
.xsl:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="">
<html><body>
<h1> </h1>
<table width="640">
<xsl:applytemplates/>
</table>
</body></html>
</xsl:template>
<xsl:template match="">
<tr>
<td><xsl:number/></td>
<xsl:applytemplates/>
</tr>
</xsl:template>
<xsl:template match=" | | ">
<td><xsl:valueof select="."/></td>
</xsl:template>
</xsl:stylesheet>
?
, .
.
<>,
, <>.
HTML,
<xsl:applytemplates/>,
<>. <>,
,
match="".
HTML <tr>, <td>,
<xsl:number/>,
( <>)
. <xsl:apply
templates/>, <>
.
<>
<>, <> <>,
95
, match=" |
| " ( | ).
HTML <td>),
<xsl:valueof select="."/>.
XPath ()
. .
, <
>, <> <>.
<xsl:applytemplates>,
,
.
<html>
<body>
<h1> </h1>
<table width="640">
<tr>
<td>1</td>
<td> </td>
<td> </td>
<td>8.95</td>
</tr>
<tr>
<td>2</td>
<td> </td>
<td> </td>
<td>12.99</td>
</tr>
. ...
</table>
</body>
</html>
(push proces
sing). ,
.
,
, ;
,
.
,
, ,
96
2. XSLT
. HTML
,
, , .
:
, ,
.
, ,
.
.
:
,
, <> .xsl
:
<xsl:template match="">
<tr>
<td><xsl:number/></td>
<xsl:applytemplates select=""/>
<xsl:applytemplates select=""/>
<xsl:applytemplates select=""/>
</tr>
</xsl:template>
<>, <>,
<>.
, ,
, ,
<>, <>, ,
.
,
, , , <
>, , .
:
,
, <> :
<xsl:template match="">
<tr>
97
<td><xsl:number/></td>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select=""/></td>
</tr>
</xsl:template>
(pull processing),
,
, .
, ,
, XSLT,
,
.
, .
:
<xsl:applytemplates>, ,
.
<xsl:applytemplates> (. )
.
<xsl:valueof>,
.
<xsl:foreach>,
.
<xsl:calltemplate>,
,
.
9 .
.
.
, .
,
. .
. <xsl:applytemplates>
,
98
2. XSLT
, . ,
:
<xsl:applytemplates select="1" mode=""/>
:
<xsl:template match="1" mode="">
. . .
</xsl:template>
4,
10.
, <xsl:ap
plytemplates>, ,
?
.
.
:
<xsl:applytemplates>,
,
<xsl:applytemplates>,
,
,
, .
, ,
.
<xsl:applytemplates>, .
:
<xsl:foreach select="namespace::*">
99
, , , ,
? ,
.
:
(import preceden
ce) . 3,
, <xsl:import>,
, B,
B.
.
, , .
priority
<xsl:template>
.
, . ,
/ (
<>, <>)
, *,
.
0.5 +0.5, , ,
1 ,
. <xsl:template>
4.
,
, XSLT
:
, .
,
.
, .
,
, ,
,
. .
XSLT ,
, ,
.
<xsl:variable>. :
100
2. XSLT
width 50.
XPath,
$width. <xsl:variable>
(
<xsl:stylesheet>), ;
<xsl:template> .
XSLT ,
<xsl:param>.
(, API
).
<xsl:withparam> .
:
. XSLT XPath
:
(String) Unicode,
XML.
(Number) ,
IEEE 754.
(Boolean) .
(Nodeset) .
XSLT 1.0
(Result Tree Fragment). , , ,
, .
XSLT 1.1
, .
, , .
.
. .
: , ,
.
,
9.
101
XPath
5.
XSLT XPath .
XSLT,
:
<xsl:valueof select="($x + $y) * 2"/>
$x $y , + *
.
XPath, , ,
.
XPath (Path
Expression).
.
,
.
: , ,
.
.
, .
.
5. :
child, .
attribute, .
ancestor, .
followingsiblings, ,
.
precedingsiblings, ,
.
, .
:
( ).
( ).
, ,
.
: ,
.
/ ,
. /
102
2. XSLT
, ;
. , ,
::. child
, , attribute
@.
, :
child::item/attribute::category
:
<item> ,
category. :
item/@category
, ,
, :
item[@code='T']/@category
category <item>,
code 'T'.
,
, .
5.
. , $x
x, . ,
.
: ,
, ,
,
.
:
,
, .
, .
( <xsl:variable>
<xsl:param>), , .
,
.
, .
<xsl:script> XSLT 1.1 (
4).
103
URI , XPath.
,
document(), URI,
. document()
7.
,
.
.
.
:
. ,
. ,
<xsl:applytemplates> <xsl:for
each>. current().
. ,
,
, .
.
self::node(). , a[.='']
<a>, ''.
. (>=1),
.
position().
<xsl:applytemplates> <xsl:foreach>
, ,
1...n.
,
. , , child::a[position()
!= 1] <a>, .
. (> =1),
.
last(). , , child::a[position()
!= last()] <a>,
.
XSLT XPath
. XSLT
, XPath ,
.
<xsl:applytemplates> <xsl:foreach>,
,
. XPath,
;
104
2. XSLT
;
.
, ,
, key()
<xsl:key>;
,
.
XSLT ,
, .
VBScript JavaScript.
,
,
, . , ,
boolean(), number() string().
:
0
'false'
1 'true'
0
105
,
, ,
. XSLT 1.0
, ; MSXML3, ,
msxml:nodeset().
. .
: ,
, ,
, . :
,
, :
, , . ,
,
, 8.
XPath .
,
true() false().
, = !=,
and or
not().
SQL, XPath .
, ;
. null
SQL XPath ,
,
. ,
name, @name='Boston' @name!='Bos
ton' . not(@name='Boston')
.
.
(EqualityExpr) (Relati
onalExpr) 5.
106
2. XSLT
XPath
(64), IEEE 754.
IEEE
(IEEE Standard for Binary FloatingPoint Arithmetic. ANSI/IEEE Std. 754
1985)
, Java
. , ,
Java,
; .
, XPath
, . ,
1000000000000, 1.0E12.
IEEE 754
:
. ,
.
.
.
. ,
: .
.
.
NaN
()
. ,
,
null SQL.
107
XPath. ,
:
XPath
0
1 div 0
1 div 0
NaN ()
number (NaN)
: 10 , ,
,
. , ,
,
$x div 1.
, NaN, .
:
(lessthan)
(greaterthan),
<xsl:applytemplates> <xsl:foreach> ,
<xsl:sort datatype="number">.
NaN ,
<, <=, > >= , NaN.
<xsl:sort>
, NaN,
( ,
).
NaN
XSLT 1.0,
. XSLT,
.
108
2. XSLT
. , =, <= >= ,
!=, < > .
; ,
1.0 div $x , $x
, , $x
.
= , NaN,
!= ,
NaN. ,
; $x=$x ,
$x<$y , $y>$x.
, $x NaN, :
<xsl:if test="$x!=$x">
, , $x
, :
<xsl:if test="string($x)='NaN'">
, null SQL, ,
. , SQL null=null
null, not(null=null) null;
XPath NaN=NaN ,
not(NaN=NaN) .
XPath ,
:
<, <=, > >=. ,
XML , < <.
= !=.
.
*, div mod.
+ .
number(), .
string() formatnumber(),
.
boolean(), .
round(), ceil() floor(),
.
sum(), .
IEEE 754. XPath
, Java,
109
.
Java.
XPath .
, ,
, , ,
, ,
, NaN.
NaN NaN.
, sum() , ,
,
sum() NaN.
XPath ,
,
, XML: , , Unicode.
XPath
, ''
"".
, "John's".
XPath
XML,
.
5.
SQL, null . ,
,
.
.
ASCII (
#x20) #x9, #xA #xD (,
, ).
= !=.
(
, SQL).
, Uni
code , .
: , ( ,
, , ASCII),
,
translate(). ,
.
110
2. XSLT
,
, ,
: < > .
( )
, ;
,
.
,
stringlength(), XML, 16
Unicode. , Unicode
. Unicode,
Unicode 65 535 , ,
.
.
,
, .
,
.
,
. ;
,
.
; , .
, @name
name ,
, name,
, .
,
, , ,
. , :
<xsl:if test="@name">
, name.
,
. , /
, . ,
, ,
, count(/) 1.
,
.
,
111
: ,
, (
) ,
. ,
.
:
, , ,
.
XSLT ,
. XSLT 1.0
, .
,
, ,
. ,
: ,
<xsl:copyof>,
( ).
,
.
XSLT 1.1
, .
, ,
, ,
. ,
,
.
XSLT 1.1 .
,
, ,
(treevalued variable).
XSLT.
,
.
XML,
,
. ,
XML : ,
, , .
:
<xsl:variable>,
:
112
2. XSLT
<xsl:variable name="tree"
>AAA<xsl:element name="x">
<xsl:attribute name="att">attvalue</xsl:attribute>
BBB</xsl:element>
<xsl:element name="y"
/>CCC</xsl:variable>
( ,
,
.
3.)
, .
; , , ,
. ,
.
. 2.9.
, XSLT 1.0, ,
: (
)
<xsl:copyof>
.
: AAABBBCCC.
XSLT 1.1 .
:
113
,
<xsl:applytemplates>.
, ,
.
,
, <xsl:valueof select=$tree/x/@att"/>
attvalue.
sum() count(), count($tree//*)
2 ( ).
, ,
.
, ,
, $mm:
<xsl:variable name="months">
</></></></></></>
</></></></></></>
</xsl:variable>
. . .
<xsl:valueof select="name($months/*[position()=$mm])"/>
XSLT 1.0 :
<xsl:valueof select="name(xx:nodeset($months)/*[position()=$mm])"/>
XSLT.
,
, XSLT.
,
.
,
XSLT, XML; ,
DOM.
,
, XSLT,
.
XSLT,
.
XSLT.
.
,
,
4 8. ,
, .
,
, ,
.
:
: ,
,
<xsl:import> <xsl:include>.
<xsl:stylesheet> ( <xsl:transform>),
.
<?xmlstylesheet?>,
,
.
,
, <xsl:stylesheet>
<xsl:transform>; 4.
, <xsl:stylesheet>
<xsl:template match="/"> , XSLT
,
.
115
,
, ,
, .
,
, XSLT.
,
, W3C,
.
,
.
XSLT,
, ,
.
,
.
: ,
,
.
, .
,
.
XSLT .
,
, .
. ,
, , ,
<?xmlstylesheet?> ,
, API,
.
<xsl:include> <xsl:import>
. , ,
.
116
3.
: <xsl:include>
, .xml, :
<?xml version="1.0" encoding="utf8"?>
<>
<> </>
<> XSLT</>
</>
</>
<> XSLT 1.1 XPath 1.0,
World Wide Web
</>
</>
<xsl:include>.
, , <>
, <>
, .
:
.xsl, .xsl .xsl. .xsl
; ,
XSLT 1.1, ,
Java.
, .
,
.
.xsl
, .xsl, :
<?xml version="1.0" encoding="utf8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:include href=".xsl"/>
<xsl:include href=".xsl"/>
<xsl:output method="xml" encoding="utf8" indent="yes"/>
<xsl:stripspace elements="*"/>
<xsl:template match="">
<><xsl:valueof select="$date"/></>
117
</xsl:template>
<xsl:template match="">
<><xsl:calltemplate name="copyright"/></>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copyof select="@*"/>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<xsl:include>,
. <xsl:output> ,
XML c Unicode ,
XML. <xsl:stripspace> ,
;
. , : <>,
<> .
<> ,
$date.
, .xsl, .
<>
, copyright.
, .xsl,
.
, ,
(match="*"),
, . <xsl:copy> <xsl:copyof>
4.
.xsl
, .xsl, ,
. Java
java.util.Date, .
.
<xsl:script>, XSLT 1.1.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1"
xmlns:Date="java:java.util.Date"
>
<xsl:script implementsprefix="Date"
language="java" src="java:java.util.Date"/>
118
3.
<xsl:variable name="date"
select="Date:tostring(Date:new())"/>
</xsl:stylesheet>
XSLT
<xsl:script>, XSLT 1.1,
.
Java
: . .
.xsl
, .xsl copyright,
.
<xsl:calltemplate> .
$owner; , .
<xsl:template>
.
.
<?xml version="1.0" encoding="iso88591"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:variable name="owner">Wrox Press</xsl:variable>
<xsl:template name="copyright"
>Copyright <xsl:valueof select="$owner"/> 2001</xsl:template>
</xsl:stylesheet>
, .xsl .xsl
.
, $date co
pyright .
119
;
.
, <xsl:include> <xsl:import>
, . ,
, ,
, .
, XML (,
, , . . 126).
( XML)
<xsl:stylesheet> <xsl:transform>:
. ,
<xsl:stylesheet> <xsl:transform>,
(
, ).
, XSLT,
(. . 129).
<xsl:include> <xsl:import>
. ,
<xsl:import> :
. href,
URI. URL,
. , <xsl:include href="
mod1.xsl"/> mod1.xsl,
, .
<xsl:include> <xsl:import> ,
:
<xsl:include>
,
<xsl:stylesheet>, , <xsl:include>.
, ,
,
<xsl:include>.
<xsl:import>
,
,
.
, , .
, ,
<xsl:import> 4.
, , :
,
.
120
3.
<xsl:template> match.
, ,
, , ,
,
. , ,
,
,
.
A , B C,
. 3.1, A , B C, C
, B, <xsl:import>, B,
<xsl:import>, C.
. 3.1.
<xsl:include> ,
, .
(
,
<xsl:include>),
. , ,
.
: ,
.
.
4, ,
<xsl:import>.
121
: <xsl:import>
<xsl:include>, , <xsl:import>
.
.xml.
, .xsl
$owner, . ,
copyright,
. , ,
(
principal2.xsl).
.xsl
<xsl:import>, <xsl:include>,
$owner,
. , <xsl:import> .
<?xml version="1.0" encoding="utf8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:import href=".xsl"/>
<xsl:variable name="owner">Wrox Press Ltd</xsl:variable>
<xsl:include href=".xsl"/>
<xsl:output method="xml" encoding="utf8" indent="yes"/>
<xsl:stripspace elements="*"/>
<xsl:template match="">
<><xsl:valueof select="$date"/></>
</xsl:template>
<xsl:template match="">
<><xsl:calltemplate name="copyright"/></>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copyof select="@*"/>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
122
3.
,
<xsl:include>, <xsl:import>. ,
$owner . , <xsl:include>
,
.
, ,
.
.
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href=".xsl"/>
<xsl:import href=".xsl"/>
</xsl:stylesheet>
,
, .
,
.xsl.
.xsl,
.
<xsl:include>,
, , , . , ,
, .
, , <xsl:attributeset>,
,
( <xsl:attributeset> 4).
,
<xsl:import>, <xsl:include>.
, <xsl:include> <xsl:import> href
:
<xsl:stylesheet>
123
,
. ,
,
, .
.
,
<xsl:import> .
G, (
, ) A,
( )
B. : A B
,
G.
, .
<xsl:stylesheet>
<xsl:stylesheet> ( <xsl:transform>, )
.
<xsl:stylesheet> . , xsl,
, ,
. ,
URI http://www.w3.org/1999/XSL/Transform.
, version. ,
<xsl:stylesheet> :
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
, URI
http://www.w3.org/TR/WDxsl, Microsoft,
XSLT.
Internet Explorer 5. IE5 (
WDxsl, Microsoft
XSL) XSLT, .
WDxsl . Wrox Press XML
IE5 (XML IE5 Programmer's Reference, ISBN 1861001576). Microsoft
MSXML,
XSLT 1.0, A.
, ,
<xsl:stylesheet> 4. :
id ,
.
.
124
3.
extensionelementprefixes ,
,
XSLT.
excluderesultprefixes ,
, ,
. ,
.
,
<xsl:stylesheet>; ,
.
<xsl:stylesheet>
. , extension
elementprefixes excluderesultprefixes,
, ,
<xsl:stylesheet>. ,
saxon ,
<xsl:stylesheet> :
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
version="1.0"
extensionelementprefixes="saxon"
>
<xsl:stylesheet>
,
.
.
<?xmlstylesheet?>
XSLT XPath,
, W3C,
http://www.w3.org/TR/xmlstylesheet. XSLT
, , XSLT
, ,
.
<?xmlstylesheet?> XML
,
.
<?xmlstylesheet?>, ,
.
href, URI
( ), type,
125
<?xml5stylesheet?>
, .
XSLT, CSS.
W3C , XSLT text/xml,
application/xml; Microsoft Internet Explorer 5
text/xsl.
XML ,
( xmlstylesheet), .
="
", ,
xmlstylesheet . ="
" .
stylesheet?> :
<?xml
href
URI
URI .
URL XML,
,
( #styleB),
.
.
type
MIME
,
; text/xml text/xsl (.
).
title
<?xml
stylesheet?>, ,
.
, .
,
.
media
, "print",
"projection" "aural".
HTML 4.0.
.
charset
XSLT
, , XML
, , .
iso88591
alternate
"yes" "no"
"no",
. "yes",
.
126
3.
<?xmlstylesheet?>, ,
,
. href
URL. :
<?xmlstylesheet type="text/xsl" href="../style.xsl"?>
CSS, <?xml
stylesheet?>, .
.
,
,
<xsl:import>.
, ,
, ,
title media.
, MSXML3 Microsoft,
.
<?xmlstylesheet?> ,
,
. ,
XML ;
,
,
.
, XML
,
, .
<?xmlstylesheet?>
, .
,
:
XSLT .
,
XML.
XML, ,
.
CSS. ,
, ,
,
.
127
, ,
, ,
, .
XSLT .
, .
<xsl:stylesheet> <xsl:transform>,
XML ( ).
<xsl:stylesheet> id,
<?xmlstylesheet?>, :
:
,
XML, .
embedded.xsl ,
, :
<?xml version="1.0"?>
<?xmlstylesheet type="text/xml" href="#style1"?>
<>
< ="">
<> </>
<> </>
<>8.95</>
</>
< ="">
<> </>
<> </>
<>12.99</>
</>
< ="">
<> </>
<> </>
<>8.99</>
</>
< ="">
<>. . . </>
<> </>
<>22.99</>
</>
<xsl:stylesheet id="style1" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="xsl:stylesheet"/>
128
3.
<xsl:template match="">
<html><body>
<h1> </h1>
<table border="1">
<xsl:applytemplates/>
</table>
</body></html>
</xsl:template>
<xsl:template match="">
<tr><xsl:applytemplates/></tr>
</xsl:template>
<xsl:template match=" | | ">
<td><xsl:valueof select="."/></td>
</xsl:template>
</xsl:stylesheet>
</>
Saxon,
( Saxon 6):
saxon a embedded.xsl
a Saxon
<?xmlstylesheet?> ,
. Saxon (
)
, , ,
, .
. 3.2.
,
<xsl:stylesheet>. ,
,
. ,
129
<xsl:stylesheet>, , .
,
. ,
//,
<>
.
. ,
.
,
.
, ,
. , exclude
resultprefixes <xsl:stylesheet>.
,
<xsl:stylesheet> <xsl:trans
form>. ,
.
<xsl:stylesheet> <xsl:transform>,
.
XSLT .
, , <xsl:import>,
, .
; ,
, XSLT ,
.
, XSLT
, ,
.
, ,
:
, XSLT
,
,
.
130
3.
,
XSLT
, XSLT,
:
<xsl:attributeset>
<xsl:decimalformat>
<xsl:import>
<xsl:include>
<xsl:key>
<xsl:namespacealias>
<xsl:output>
<xsl:param>
<xsl:preservespace>
<xsl:script>
<xsl:stripspace>
<xsl:template>
<xsl:variable>
4. XSLT
( URI http://www.w3.org/
1999/XSL/Transform) .
,
, ,
URI,
XSLT. ,
: , Saxon URI
http://icl.com/saxon.
,
,
XSLT. ,
, , ,
extensionelementprefixes.
,
,
XPath ( XSLT 1.1
<xsl:script>,
).
.
.
,
, ,
URI,
XSLT. , URI URI
, .
XSLT.
XSLT 1.0 , ,
, . .
131
,
document(), 7.
,
, document().
, ,
, :
<user:data xmlns:user="http://acme.com/">
<message nr="1"> </message>
<message nr="2"> </message>
<message nr="3"> sales </message>
</user:data>
,
:
<xsl:template name="displaymessage">
<xsl:param name="messagenr"/>
<xsl:message xmlns:user="http://acme.com/">
<xsl:valueof
select="document('')/*/user:data/message[@nr=$messagenr]"/>
</xsl:message>
</xsl:template>
<xsl:valueof> XPath
select .
XPath ,
document(''), ,
*, (
<xsl:stylesheet>), user:data <user:data>,
message[@nr=$messagenr] <message>, nr
$messagenr .
,
:
<xsl:if test="string(number(@sales))='NaN'">
<xsl:calltemplate name="displaymessage">
<xsl:withparam name="messagenr" select="3"/>
</xsl:calltemplate>
</xsl:if>
<xsl:if> , sales
: , ,
NaN, .
,
: sales .
( , ,
<xsl:message>.
.)
132
3.
,
, . ,
,
.
XSLT 1.1 ,
. :
<user:data xmlns:user="http://acme.com/">
<message nr="1"> </message>
<message nr="2"> </message>
<message nr="3"> sales </message>
</user:data>
:
<xsl:variable name="data">
<message nr="1"> </message>
<message nr="2"> </message>
<message nr="3"> sales </message>
</xsl:variable>
:
<xsl:valueof select="document('')/*/user:data/message[@nr=$messagenr]"/>
:
<xsl:valueof select="$data/message[@nr=$messagenr]"/>
,
<xsl:stylesheet> .
XSLT
.
HTML,
. ,
( HTML, ),
XSLT .
,
<xsl:stylesheet> <xsl:transform>.
,
XSLT.
XSLT xsl:version.
XSLT 1.1 1.0 1.1 (1.1 ,
, XSLT 1.1,
1.0 , ,
XSLT 1.0). xsl:version 1.0 1.1,
.
( . 159).
133
:
HTML
XSLT
. (
) http://www.wrox.com.
simplified.xsl,
books.xml, .
.xsl
.xml, :
<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsl:version="1.0">
<head>
<title> </title></head>
<body>
<h1> </h1>
<table border="2">
<xsl:foreach select="//">
<xsl:sort select=""/>
<tr>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select="@"/></td>
<td><xsl:valueof select=""/></td>
</tr>
</xsl:foreach>
</table>
</body>
</html>
.xml (
2), ,
:
. 3.3.
134
3.
,
( <html>)
<xsl:template> match="/", ,
<xsl:stylesheet>. xsl:version
version <xsl:stylesheet>. ,
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head><title> </title></head>
<body>
<h1> </h1>
<table border="2">
<xsl:foreach select="//">
<xsl:sort select=""/>
<tr>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select="@"/></td>
<td><xsl:valueof select=""/></td>
</tr>
</xsl:foreach>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
match="/" ,
, .
2,
, ,
, . /
.
.
,
XSLT . ,
,
.
, ,
<xsl:stylesheet> <xsl:template>.
,
, ,
, .
135
<xsl:template> ,
<xsl:param>, .
XSLT ,
<xsl:template>,
.
XSLT
. , ,
,
, <xsl:template>.
, <xsl:variable> <xsl:if>
, <xsl:template> (
<xsl:param>), . ,
. ,
:
<xsl:template match="para">
<xsl:if test="position()=1">
<hr/> o 0 o <hr/>
</xsl:if>
<xsl:applytemplates/>
<xsl:if test="position()=last()">
<hr/> o 0 o <hr/>
</xsl:if>
</xsl:template>
,
2, , .
.
: , XSLT (
<xsl:if>) (, <hr>),
, (. 3.4).
XSLT
, C
Java; , C Java,
, .
. ,
XSLT .
.
, , ,
. ,
, ,
xml:space,
.
136
3.
. 3.4.
, , ,
<xsl:text>,
.
: XSLT,
.
.
XSLT
XSLT :
<xsl:applyimports>
<xsl:applytemplates>
<xsl:attribute>
<xsl:calltemplate>
<xsl:choose>
<xsl:comment>
*
<xsl:copy>
<xsl:copyof>
<xsl:document>*
<xsl:element>
<xsl:fallback>
<xsl:foreach>
<xsl:if>
<xsl:message>
<xsl:number>
<xsl:processinginstruction>
<xsl:text>
<xsl:valueof>
<xsl:variable>
XSLT
. XSLT, <xsl:withparam>, <xsl:sort>
<xsl:otherwise>, ,
. <xsl:param> ,
137
<xsl:template>,
, , .
, .
XSLT 4.
XSLT, ,
. ( . 159).
,
, ,
XSLT. ,
, extensionele
mentprefixes <xsl:stylesheet>
xsl:extensionelementprefixes ,
, .
, . XSLT 1.0
( XSLT 1.1
<xsl:document>). :
Saxon <saxon:group>
( GROUP BY SQL) ,
XSLT .
, , ,
.
, ,
. XSLT 1.1
, XSLT;
, Java JavaScript.
<acme:instruction>,
, xsl:extension
elementprefixes, :
<acme:instruction
xmlns:acme="http://acme.co.jp/xslt"
xsl:extensionelementprefixes="acme"/>
XSLT , , .
, XSLT
.
, ,
.
138
3.
, , ,
, , Xalan,
, , Microsoft?
, ( ,
), ,
XSLT:
<xsl:fallback>, ,
.
.
<xsl:fallback> , XSLT
, .
. 159, 4.
,
XSLT ,
(, <hr/>
). ,
.
, :
.
, (
) .
, .
,
, .
,
4 XSLT.
xsl:excludere
sultprefixes
,
(.
)
,
.
.
139
xsl:extension
elementprefixes
,
(.
)
,
.
,
,
,
.
xsl:version
XSLT 1.0:
1.0, XSLT,
,
XSLT,
1.0.
,
(. ). XSLT
1.1: 1.0 1.1 ;
XSLT,
XSLT 1.1.
xsl:useattribu
tesets
,
<xsl:attributeset>,
(.
)
,
,
.
XPath ,
,
,
,
.
. 148.
,
. ( ),
XML :
, , . ,
:
<TD xsl:useattributesets="blue italic centered"/>
140
3.
.
, XSLT, ,
/ .
,
.
,
:
<TD> </TD>
<TD>
, .
XML HTML, ,
, . ,
: ,
,
, .
,
, :
, ,
, .
, :
<TD><xsl:valueof select="."/></TD>
<TD>
. ,
XSLT, ,
, <TD> .
<xsl:valueof select=".">
. , $83.99,
:
<TD>$83.99</TD>
:
<TD> <TD>
<xsl:valueof> , ($83.99)
</TD> </TD>
, ,
, : ,
,
.
141
,
. <TD>
<TD>.
:
. <TD> </TD> ,
XML HTML.
, ,
, ,
, .
, ,
,
.
, , HTML
, <item> XML .
142
3.
XML,
, <item>, 1, 6, 11 . .
:
<xsl:template match="item[position() mod 5 = 1]">
<tr>
<xsl:foreach select=". | followingsibling::item[position() < 5]">
<td><xsl:valueof select="."/></td>
</xsl:foreach>
</tr>
</xsl:template>
<xsl:template match="item"/>
<item>,
; <tr>
<td>, <item>
. <item>,
, ,
.
,
xsl , ,
. , :
<TD><IMG src="picture1.gif"/></TD>
.
<TD>, , ,
, <IMG>,
<TD>
src. ,
, :
. 3.6.
143
({ }), (
).
XPath, ;
, ,
. , , .xml,
, :
<xsl:template match="/">
<xsl:foreach select="//">
<div id="div{position()}">
<xsl:valueof select=""/>
</div>
</xsl:foreach>
</xsl:template>
position()
1, 2, 3 4, :
<div
<div
<div
<div
id="div1"> </div>
id="div2"> </div>
id="div3"> </div>
id="div4"> </div>
:
<xsl:attribute>.
,
(
).
, XSLT
.
XML ,
, ,
, . ,
, , ,
, .
.
xsl:useattributesets, ,
:
<xsl:attributeset> .
<xsl:attribute>,
,
.
,
144
3.
, , ,
;
, CSS.
: , xsl:useattributesets,
,
, , ,
<xsl:attribute>. ,
,
. ,
.
. .
,
, xmlns xmlns:*
.
xmlns="", ,
.
, ,
,
, :
URI XSLT http://
www.w3.org/1999/XSL/Transform .
,
, .
extensionelementprefixes
<xsl:stylesheet> xsl:extensionelement
prefixes ,
.
.
excluderesultprefi
xes <xsl:stylesheet> xsl:excluderesult
prefixes
.
, , :
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
145
version="1.1"
xmlns:Date="java:java.util.Date"
>
<xsl:script implementsprefix="Date" language="java"
src="java:java.util.Date"/>
<xsl:template match="/"
xmlns = "urn:acmecom:gregorian">
<date><xsl:valueof select="$today"/></date>
</xsl:template>
<xsl:param name="today" select="Date:toString(Date:new())"/>
</xsl:stylesheet>
<date> ,
: XSLT, java:java.util.Date
urn:acmecom:gregorian.
XSLT , .
, <date>, ,
java:java.util.Date urn:acme
com:gregorian.
: Da
te:new() Date.toString().
<xsl:script>, XSLT 1.1.
XSLT 1.0 : .
.
$today 20001318,
( ):
<date xmlns="urn:acmecom:gregorian"
xmlns:Date="java:java.util.Date">20001318</date>
,
<date>.
xmlns:Date . ,
. , XSLT
, . ,
xsl:excluderesultprefixes :
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1"
xmlns:Date="java:java.util.Date"
>
<xsl:script implementsprefix="Date" language="java"
src="java:java.util.Date"/>
<xsl:template match="/"
xmlns = "urn:acmecom:gregorian">
146
3.
<date xsl:excluderesultprefixes="Date">
<xsl:valueof select="$today"/>
</date>
</xsl:template>
<xsl:param name="today" select="Date:toString(Date:new())"/>
</xsl:stylesheet>
, ,
,
XML,
. XSLT,
, ,
, ,
.
,
XSLT .
, .
,
, ,
. ,
, .
, XSLT ,
XML,
,
,
,
.
xsl:excluderesultprefixes
, .
,
. ,
, .
,
( URI )
,
. ,
, .
, XSLT
. , ,
,
URI , :
147
<output>
<xsl:attribute name="out:file"
xmlns:out="http://domaina.com/">a</xsl:attribute>
<xsl:attribute name="out:dir"
xmlns:out="http://domainb.com/">b</xsl:attribute>
</output>
:
<output
out:file="a"
ns1:dir="b"
xmlns:out="http://domaina.com/"
xmlns:ns1="http://domainb.com/"/>
XSLT ,
,
.
, , ,
( URI ).
, URI
.
, ( URI
) ,
. ,
,
URI .
URI .
, ,
. ,
:
. ,
( ), XSLT
, .
XSLT <xsl:template>;
,
.
<xsl:namespacealias>,
URI .
. <xsl:namespacealias> 4.
148
3.
,
. :
,
, , <TD
WIDTH="{$width}">.
<xsl:attribute>,
.
XSLT
. , order="ascen
ding" order="descending" order="{$order}",
.
, .
.
XSLT, <xsl:template>.
.
,
XPath, ({ }).
XPath ,
, 2,
.
, , ,
, , ,
.
fancyA.gif
fancyB.gif
fancyC.gif
fancyD.gif
fancyE.gif
. 3.7.
(
, ,
).
substring(), 7.
<xsl:template match="para">
<p><img src="fancy{substring(.,1,1)}.gif"/>
<xsl:valueof select="substring(.,2)" /></p>
</xsl:template>
149
, A ( ),
src <img> img src="fancyA.gif"
:
. 3.8.
{ }
( HTML
), : {{ }}.
,
. .
.
XPath
; XPath.
; , :
<a href="#{id( 'A{@nr}' )}"> <! >
:
<a href="#{id( concat('A', @nr) )}">
concat(), 7, .
. ,
XSLT .
, :
, XSLT
150
3.
<xsl:attribute>
name, namespace
<xsl:document>
(: XSLT 1.1)
<xsl:element>
name, namespace
<xsl:number>
<xsl:output>
<xsl:processing
instruction>
name
<xsl:sort>
,
,
. , , ,
<xsl:calltemplate>,
:
<! >
<xsl:param name="tname"/>
<xsl:calltemplate name="{$tname}"/>
<! >
, name (
<xsl:calltemplate>) <xsl:calltemplate>
.
?
,
, XSLT:
. ,
. XSLT 1.1
<xsl:output>
.
,
XPath (pattern). ,
,
.
,
,
. ,
151
.
,
.
,
XML, , xml:space,
xml:lang (xmlns xmlns:prefix).
, XML ,
XSLT . xml:base
: ,
XML,
, , ,
.
xml:base .
( xml:base,
W3C XML Base,
XSLT 1.1.)
. ,
, terminate <xsl:message>
, ,
.
XPath ,
, .
2: .,
, position(), .
,
. ,
,
<xsl:applytemplates> <xsl:foreach>;
(
<xsl:output>),
.
HTML
, W3C, XSLT,
.
XSLT
:
152
3.
,
( ,
) ,
, .
XSLT
, ,
, ,
.
,
, .
,
,
.
, ,
.
.
:
, XSLT, ,
, ,
URI
. ,
<xsl:template> acme:debug,
,
. acme:repeat="2",
,
. (,
.)
; , URI
. <msxsl:script>
Microsoft VBScript JScript (
<xsl:script> XSLT 1.1).
, URI ,
.
XSLT
,
. lang
<xsl:number> <xsl:sort>,
, method <xsl:output>,
, , format
<xsl:number>,
, ,
. ,
153
systemproperty(),
, ,
language <xsl:script> XSLT 1.1.
XSLT , Java Java
Script. , :
(,
)
,
, XSLT
,
,
XSLT XPath ( 7),
, .
XSLT 1.0 ,
, ,
. ,
XSLT 1.0 ,
XSLT ,
, ,
.
XSLT 1.1 .
XSLT 1.1
, Java JavaScript ( ECMAScript).
, ,
, , ,
Java XSLT
, Java,
JavaScript ,
JavaScript.
XPath DOM.
8.
XPath (. 5)
, .
, ,
: not()
:
<xsl:if test="not( @name = '' )">
154
3.
, . URI
, ,
<xsl:script>, , , ,
. ,
, ja
va.lang.Math Java:
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:Math="java:java.lang.Math">
<xsl:script implementsprefix="Math" language="java" src="java:java.lang.Math"/>
<xsl:variable name="randomnumber" select="Math:random()"/>
, Java
( Java ) ,
, XSLT,
.
<xsl:script> XSLT 1.1 XSLT 1.0
, URI
Java. ,
, ,
URI .
xt :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="randomnumber" select="Math:random()"
xmlns:Math="http://www.jclark.com/xt/java/java.util.Date"/>
, Saxon
Xalan, URI
, <xsl:script>,
.
,
,
XPath. .
,
, Java java.util.Date.
Date,
, toString(),
, .
:
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:Date="java:java.util.Date">
<xsl:script implementsprefix="Date" language="java" src="java:java.util.Date"/>
155
Date:new() Date
, URI ,
java.util.Date, ,
Java. $today
, Java java.util.Date.
<xsl:valueof>
, toString()
( Date).
;
, Date:toString($today) XPath
today.toString() Java. ,
.
XSLT 1.1
JavaScript: ,
, JavaScript
<xsl:script>. MSXML3 Microsoft (
) XSLT 1.0,
, , <msxsl:script>
<xsl:script>.
,
XSLT Microsoft, ,
:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:js="javascript:myextensions">
<msxsl:script
xmlns:msxsl="urn:schemasmicrosoftcom:xslt"
language="VBScript"
implementsprefix="ms"
>
Function ToMillimetres(inches)
ToMillimetres = inches * 25.4
End Function
</msxsl:script>
<xsl:template match="/" >
<xsl:variable name="test" select="12"/>
<size><xsl:valueof select="ms:ToMillimetres($test)"/></size>
</xsl:template>
</xsl:stylesheet>
156
3.
functionavailable() ,
. :
<xsl:choose xmlns:acme="http://acme.co.jp/xslt">
<xsl:when test="functionavailable('acme:moonshine')">
<xsl:valueof select="acme:moonshine($x)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>*** , moonshine ***</xsl:text>
</xsl:otherwise>
</xsl:choose>
, XSLT,
acme:moonshine(),
, :
, .
,
functionavailable(),
, .
,
. ,
,
. Xalan
,
, XSLT.
, XSLT ,
. , ,
:
. , , xt,
:
, .
,
, ,
, . ,
,
, ,
.
8.
, ,
,
.
extensionelementprefixes <xsl:stylesheet> xsl:exten
157
sionelementprefixes
, .
, Saxon <saxon:while>
, .
XSLT,
.
<saxon:while> .
, .
Java
java.util.StringTokenizer:
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:Tokenizer="java:java.util.StringTokenizer">
<xsl:script implementsprefix="Tokenizer"
language="java" src="java:java.util.StringTokenizer"/>
<xsl:template name="tokenize">
<xsl:param name="sentence"/>
<xsl:variable name="tok" select="Tokenizer:new($sentence)"/>
<saxon:while test="Tokenizer:hasMoreTokens($tok)"
xsl:extensionelementprefixes="saxon"
xsl:excluderesultprefixes="Tokenizer"
xmlns:saxon="http://icl.com/saxon">
<>
<xsl:valueof select="Tokenizer:nextToken($tok)"/>
</>
</saxon:while>
</xsl:template>
</xsl:stylesheet>
, , , saxon
, <saxon:while>
. xsl:excluderesultprefixes
,
.
:
<xsl:template match="/">
<xsl:calltemplate name="tokenize">
<xsl:withparam name="sentence"> </xsl:withparam>
</xsl:calltemplate>
</xsl:template>
:
<></><></><></><></>
158
3.
<xsl:stylesheet>
, <>. ,
xsl:excluderesultprefixes.
,
,
, .
, XSLT
; ,
, ,
.
,
(,
Saxon Xalan), API, , ,
, .
,
.
, XSLT
,
, (
). ,
, ,
, .
,
, : element
available() <xsl:fallback>.
elementavailable()
functionavailable(). :
<xsl:choose xmlns:acme="http://acme.co.jp/xslt">
<xsl:when test="elementavailable('acme:moonshine')">
<acme:moonshine select="$x" xsl:extensionelementprefixes="acme"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>*** , moonshine ***</xsl:text>
</xsl:otherwise>
</xsl:choose>
, elementavailable()
( acme)
, ,
.
<xsl:fallback> ( 4)
, , ,
.
:
159
<acme:moonshine select="$x"
xmlns:acme="http://acme.co.jp/xslt" xsl:extensionelementprefixes="acme">
<xsl:fallback>
<xsl:text>*** , moonshine ***</xsl:text>
</xsl:fallback>
</acme:moonshine>
, XSLT
, ,
<xsl:fallback>. <xsl:fallback>,
. ,
<xsl:fallback>, . ,
XSLT ,
<xsl:fallback>.
,
<xsl:fallback>.
XSLT, <xsl:fallback> ,
<xsl:copyof> <xsl:valueof>. ,
<xsl:fallback>, .
, ;
, ,
.
, ,
,
XSLT,
,
XSLT.
, , .
XSLT: 1.0
1.1 ( ,
1.0).
.
, 1.0 .
( version=1.0
version=1.1) <xsl:stylesheet>. versi
on=1.0 , ,
XSLT 1.0, version=1.1 ,
, 1.1.
, XSLT 1.0,
version=1.0, XSLT
160
3.
.
.
,
1.1, version=1.1. ,
XSLT 1.1, ,
XSLT 1.1, XSLT 1.0
. XSLT 1.1
,
version=2.0 ,
.
XSLT ,
XSLT,
, .
, , , ,
, .
,
, :
XSLT,
,
<xsl:fallback>.
, ,
.
,
, ,
.
, functionavailable()
.
XPath,
, XPath 1.0,
, . (
XSLT 1.0 XSLT 1.1 XPath 1.0;
XPath .)
,
, , <xsl:sty
lesheet> , 1.0 ( XSLT 1.1)
1.1.
, xsl:version
, ,
1.0 1.1.
, 1.0 1.1,
, ,
XSLT 1.1, XPath ,
XPath 1.0, , ,
.
161
, , :
, 1.0
systemproperty('xsl:version'),
XSLT , , , .
, , ,
,
.
, ,
XSLT 1.1, XSLT 1.0, XSLT 1.1.
XSLT ,
,
, . ,
1.1 systemproperty('xslversion'),
, :
, !
.
HTML, , ,
, HTML
162
3.
.
, ,
.
:
,
,
.
,
,
, , .
:
Unicode
#x9
#xA
#xD
#x20
XSLT , XML.
, (#xA0),
HTML , ,
, , .
.
 
, .
  XSLT,
XML, ,
.
XML
.
, , ,
, #PCDATA
, . ,
,
.
XSLT ,
DTD, ,
.
( xml:space)
( <xsl:stripspace> <xsl:preserve
space>), 4.
163
XML,
, XSLT :
, ,
#xA.
Unix, Windows
Macintosh.
XML .
,
	 &#A;;
(, CDATA) XML
.
,
XPath . ,
, ,
. :
<xsl:if test="contains(address, '
')">

,
,
XML ,
, .
, ,
;
,
.
XSLT , XML
, , XSLT.
XSLT , XSLT
.
MSXML3 Microsoft DOM,
DOM MSXML3 ,
, . ,
XSLT,
preserveWhitespace Document
true.
XML , XSLT
.
,
,  :
(
, DOM).
, ,
,
164
3.
<xsl:stripspace> .
xml:space ; . <xsl:text>
4.
,
. , :
<>
<>Abelard and Heloise</>
<>Some notes towards a family tree</>
<>Brenda M Cook</>
<>
The story of Abelard and Heloise is best recalled
nowadays from the stage drama of 1970 and it is perhaps inevitable that Diana Rigg
stripping off for Keith Mitchell should be the most enduring image of this historic
couple in some people's minds.
</>
</>
: <>, <
>, <> <>
<> <>. XML
XSLT,
.
<xsl:stripspace elements=""/>.
<>
.
, ,
,
.
.
normalizespace(),
.
normalizespace() 7.
, XSLT ,
, ,
. ,
, ,
, .
.
<>
<> </>
<> Lloyds</>
165
<>
71 Lombard Street
London, UK
<>EC3P 3BS</>
</>
</>
? ,
:
<>
<> </>
<> Lloyds</>
<>
71 Lombard Street
London, UK
<>EC3P 3BS</>
</>
</>
<
> <> ,
, .
</> <> </
> <>.
<>
, ,
. ,
:
<>
<> </>
<> Lloyds</>
<>
71 Lombard Street
London, UK
<>EC3P 3BS</>
</>
</>
? , <xsl:stripspace>
, ,
(
), (
),
.
, ,
<>,
:
<xsl:stripspace elements=""/>
166
3.
, , ,
.
, ,
,
, <xsl:text>.
, ,
,
<xsl:text>, :
<xsl:valueof select="[1]"/>
<xsl:text>
</xsl:text>
<xsl:valueof select="[2]"/>

,
,
; ,
.
XSLT
,
XML , XSLT.
,
, ,
. , <>
:
<xsl:applytemplates/>
<> ,
, .
,
.
<xsl:number> position() co
unt() ,
, .
, <>, <> <>
2, 4 6, 1, 2 3.
, ,
. :
<para>
<name> </name><email>jjc@jclark.com</email>
</para>
167
, ,
, .
, (
, , ),
.
,
, :
<xsl:stripspace elements="*"/>
, ,
, :
<xsl:stripspace elements="*"/>
<xsl:preservespace elements="para h1 h2 h3 h4"/>
(
) XML xml:space="preserve",
: ,
, ,
xml:space="default"
.
, , <xsl:stripspace>
.
:
, .
HTML
,
.
( , )
,
.
,
:
, , <xsl:output>
indent="no", .
, , ,
, .
168
3.
,
<xsl:text> . ,
,
,
, :
<xsl:foreach select="item">
<xsl:valueof select="."/>,
</xsl:foreach>
, , ,
:
<xsl:foreach select="item">
<xsl:valueof select="."/>,<xsl:text/>
</xsl:foreach>
,
normalizespace(),
.
,
, , ,
, ,
<xsl:stripspace>.
, ,
<xsl:text>, .
, HTML,
:
<xsl:foreach select="line">
<xsl:valueof select="."/><br/>
</xsl:foreach>
,
HTML ,
. <br>
:
<xsl:foreach select="line">
<xsl:valueof select="."/><br/><xsl:text>
</xsl:text>
</xsl:foreach>
: ,
(#xa0), ,
. :
<xsl:foreach select="line">
169
<xsl:valueof select="."/><br/> 
</xsl:foreach>
,  
, .
.
,
,
<xsl:import> <xsl:include>. ,
, .
<xsl:stylesheet> ( <xsl:transform>),
.
<?xmlstylesheet?>,
,
, ,
, .
, ,
<xsl:stylesheet>
<xsl:transform>, ,
.
, , <xsl:styles
heet> <xsl:template match="/">, XSLT
,
.
,
,
, ,
.
,
,
XSLT.
, W3C
,
W3C,
. , ,
,
.
170
3.
, , XSLT
,
.
.
XSLT,
; XPath,
; ,
;
,
XPath.
4
XSLT
XSLT. :
, XSLT
, ,
,
( )
,
XSLT
, , ,
,
,
.
: ,
, .
,
. 2 3,
.
.
172
4. XSLT
, ,
, url="../{$href}".
XSLT.
( ),
.
3
.
,
XML:
,
.
XSLT ,
. XPath:
5. ,
, , ,
.
2 .
.
, ,
, :
,
.
,
: ,
XSLT . <xsl:if>
, <xsl:stripspace> ,
<xsl:if> , <xsl:stripspace> .
3
.
, ,
: (
HTML) <p> <td>.
3 .
XSLT ,
.
6. ,
,
. , title
title, text() .
173
XML,
. color date
due. xsl:choose html:table.
,
,
,
.
2.
,
, <xsl:include>
<xsl:import>.
, .
, (
) XSLT.
<xsl:template>; XSLT,
<xsl:if> <xsl:variable>,
.
XSLT ,
,
( <xsl:template>
match) ( <xsl:template>
name).
<xsl:template>, match.
,
<xsl:variable>, ,
<xsl:variable><b></b> </xsl:variable>
XSLT 1.0
,
, .
XSLT 1.1
,
( ).
XSLT
XSLT,
, <xsl:template>
<xsl:if>.
XSLT
, ,
XSLT,
. , , ,
XSLT, ,
.
174
4. XSLT
, <xsl:applyimports>,
.
,
, , , :
, <xsl:template>
<xsl:applytemplates>
<xsl:calltemplate>
, <xsl:stylesheet>
<xsl:include>
<xsl:import>
, <xsl:valueof>
<xsl:element>
<xsl:attribute>
<xsl:comment>
<xsl:processinginstruction>
<xsl:text>
, <xsl:variable>
<xsl:param>
<xsl:withparam>
, <xsl:copy>
<xsl:copyof>
, <xsl:if>
<xsl:choose>
<xsl:when>
<xsl:otherwise>
<xsl:foreach>
<xsl:sort>
<xsl:number>
, <xsl:output>
<xsl:document>
;
.
xsl:applyimports
<xsl:applyimports>
.
.
, .
<xsl:applyimports> ,
xsl:apply5imports
175
.
. ,
, ,
. <xsl:applyimports>
super() ,
.
XSLT, 5.6
XSLT 1.0:
<xsl:applyimports/>
XSLT 1.1:
<xsl:applyimports>
<xsl:withparam> *
</xsl:applyimports>
<xsl:applyimports> ,
.
, ( XSLT 1.1)
<xsl:withparam>.
<xsl:applyimports>
. ,
<xsl:applytemplates>.
<xsl:calltemplate> .
<xsl:foreach>
, <xsl:foreach>,
.
.
176
4. XSLT
<xsl:applyimports> ,
, , <xsl:applytemplates>,
, ()
, , () ,
,
. . <xsl:import>
. 256.
, .
,
. S
T
, <xsl:import> T
, T <xsl:include>.
S T, , S,
, ,
T.
XSLT 1.1
<xsl:withparam>, <xsl:applyimports>,
, .
, <xsl:calltemplate> <xsl:apply
templates>:
<xsl:param> , ,
,
<xsl:param>. ,
<xsl:param> , ,
.
<xsl:applyimports>
.
, a.xsl,
. ,
:
<xsl:template match="">
<xsl:valueof select=""/>
<xsl:text>/</xsl:text>
<xsl:valueof select=""/>
<xsl:text>/</xsl:text>
<xsl:valueof select=""/>
</xsl:template>
, b.xsl,
. , ,
, , ,
. :
xsl:apply5imports
177
<xsl:template match="/">
<b>
<xsl:valueof select=""/>
<xsl:text>/</xsl:text>
<xsl:valueof select=""/>
<xsl:text>/</xsl:text>
<xsl:valueof select=""/>
</b>
</xsl:template>
,
. a.xsl b.xsl
:
<xsl:import href="a.xsl"/>
<xsl:template match="/">
<b>
<xsl:applyimports/>
</b>
</xsl:template>
,
,
. <xsl:import> . 256,
, .
, <xsl:template> . 349. ,
, , /
,
. , ,
, .
,
<xsl:calltemplate>
(. . 204).
(
).
. , ,
XSLT,
.
, ,
. , ,
:
, : HTML <a>
, anchor.
, ,
,
:
178
4. XSLT
<xsl:template match="*[@anchor]">
<a name="{@anchor}"/>
<xsl:applyimports/>
</xsl:template>
<xsl:import>
<xsl:applyimports>.
.
<xsl:import> . 256
<xsl:param> . 316
<xsl:withparam> . 383
xsl:applytemplates
<xsl:applytemplates> ,
, ,
.
XSLT, 5.4
<xsl:applytemplates> ,
.
select
, .
,
.
mode
. ,
,
.
,
5 (Expression)
(QName) .
xsl:apply5templates
179
<xsl:sort>.
<xsl:withparam>.
<xsl:applytemplates>
,
. select;
<xsl:sort> ( ), ,
<xsl:withparam> ( ).
.
select
select , ,
. XPath,
. (
XSLT 2.) <xsl:applytemplates
select="*"/> ,
. <xsl:applytemplates select="@width
+3"/> ,
, .
(,
), . ,
(, <xsl:apply
templates select="//item"/>) ,
, (, <xsl:applytemplates select=
"$salesfigures"/>). XPath 5.
select ,
: , ,
,
. , ,
, ;
<xsl:stripspace>
. 336. XPath, 2,
,
: ,
select, <xsl:applytemplates select="@*"/>.
<xsl:valueof>, . 366.
select child::no
de(). (, ,
),
.
180
4. XSLT
, , <xsl:apply
templates/> , .
, .
.
, ,
XPath ..
, : ,
position(),
(
position()=1 ), last(),
. ( ) 7.
, , ,
.
<xsl:sort>,
. ,
, ,
:
.
, ,
,
XML .
, document() (
7),
, ,
.
<xsl:applytemplates>
<xsl:sort>, .
<xsl:sort> .
. <xsl:sort> . 330.
,
. , <xsl:sort>
, ,
.
, .
, , ,
. ( 5.)
select="precedingsibling::*"
(
181
xsl:apply5templates
), precedingsibling ,
.
,
. , select="precedingsibling::*[1]"
, ( ) .
, ,
.
;
,
.
, ,
<xsl:template> match,
, XSLT.
<xsl:template> ,
: mode <xsl:apply
templates> mode <xsl:template>.
,
. ,
, ,
URI , .
, mode , ,
,
<xsl:applytemplates>. :
, <xsl:applytemplates>
mode.
<xsl:template> ,
, match <xsl:template>.
<xsl:template>,
, <xsl:template> . 349.
<xsl:template>,
.
:
applytemplates
, ,
<xsl:applytemplates>.
:
<xsl:applytemplates mode="mode"/>
182
4. XSLT
applytemplates
, ,
<xsl:applytemplates>.
:
<xsl:applytemplates mode="mode"/>
.
:
<xsl:valueof select=".">
.
:
<xsl:valueof select=".">
,
, <xsl:apply
templates> select.
, , :
. ,
<xsl:applytemplates mode="m"/> ,
,
<xsl:applytemplates mode="m"/> .
, ,
.
,
, .
, .
<xsl:withparam>,
<xsl:applytemplates>, ,
.
, , , ,
.
<xsl:withparam> ,
<xsl:variable>. :
select, XPath.
xsl:apply5templates
183
select , <xsl:withparam> ,
.
.
,
<xsl:withparam>, ,
. ,
, 2,
<xsl:variable> . 370.
, ,
. (
,
, ), ,
. ,
.
,
, ,
.
<xsl:withparam>
<xsl:param> ,
<xsl:withparam> <xsl:param>.
<xsl:withparam>,
<xsl:param> ,
. .
<xsl:param>,
<xsl:withparam> <xsl:ap
plytemplates>, ; .
<xsl:param> . 316. , .
,
.
, ,
. , ,
:
<xsl:template match="">
<ol>
<xsl:applytemplates>
<xsl:withparam name="" select="true()"/>
</xsl:applytemplates>
</ol>
</xsl:template>
<xsl:template match="">
<xsl:param name="" select="false()"/>
. . .
</xsl:template>
184
4. XSLT
<> <>,
$, , "".
,
<> <>,
<> ,
$ "". ,
<xsl:applytemplates>
<>,
.
,
( XPath). , ,
, .
,
,
, , ,
.
<xsl:variable>, <xsl:param> <xsl:withparam>
.
,
, ,
, .
XSLT 1.1 .
<xsl:document> ( . 231),
,
.
, .
XSLT .
<xsl:attribute>, <xsl:comment>
<xsl:processinginstruction>.
,
. <xsl:message>,
, .
,
.
<xsl:applytemplates>
. , <xsl:applytemplates>
<xsl:variable>,
, , , ,
, .
, <xsl:applytemplates>
, :
xsl:apply5templates
185
<xsl:variable name="">
<xsl:applytemplates mode=""/>
</xsl:variable>
, <xsl:applytemplates>
. , , ,
, , ,
, .
<xsl:applytemplates>. , <xsl:apply
templates>, <xsl:foreach>. ,
.
<xsl:applytemplates> <xsl:foreach>
<xsl:applytemplates> ,
.
:
, ,
, ,
. ,
, ,
.
, .
(push
processing). , ,
awk Perl,
C++ Visual Basic.
,
<xsl:foreach>
, <xsl:valueof>.
(pull processing).
<xsl:valueof> XML,
XPath .
SELECT SQL.
XSLT
.
9.
186
4. XSLT
,
.
.
,
: mode="".
:
, , .
:
, scene.xml, ( , 1
1 XML
(Jon Bosak).1
:
<?xml version="1.0"?>
<SCENE><TITLE> I. . .</TITLE>
<STAGEDIR> </STAGEDIR>
<SPEECH>
<SPEAKER></SPEAKER>
<LINE> . , .</LINE>
<LINE> , .</LINE>
</SPEECH>
<SPEECH>
<SPEAKER></SPEAKER>
<LINE> . .</LINE>
<LINE> , .</LINE>
</SPEECH>
..
</SCENE>
scene.xsl
HTML. :
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="SCENE">
<html><body>
<xsl:applytemplates select="TITLE"/>
. . . .
xsl:apply5templates
187
<xsl:variable name="speakers"
select="//SPEAKER[not(.=preceding::SPEAKER)]"/>
<h2> : <xsl:applytemplates
select="$speakers" mode="castlist"/></h2>
<xsl:applytemplates select="*[not(self::TITLE)]"/>
</body></html>
</xsl:template>
, , <SCENE>.
<TITLE> ( ),
. ,
speakers, ,
<SPEAKER>, .
select //SPEAKER
<SPEAKER>, (
, ),
, <SPEAKER>,
.
, .
<xsl:applytemplates>
castlist (
, ).
, <xsl:applytemplates>,
, (*),
<TITLE> ( ).
:
<xsl:template match="SPEAKER" mode="castlist">
<xsl:valueof select="."/>
<xsl:if test="not(position()=last())">, </xsl:if>
</xsl:template>
, <SPEAKER>
castlist.
,
.
, ,
:
<xsl:template match="TITLE">
<h1><xsl:applytemplates/></h1>
</xsl:template>
<xsl:template match="STAGEDIR">
<i><xsl:applytemplates/></i>
</xsl:template>
<xsl:template match="SPEECH">
<p><xsl:applytemplates/></p>
</xsl:template>
188
4. XSLT
<xsl:template match="SPEAKER">
<b><xsl:applytemplates/></b><br/>
</xsl:template>
<xsl:template match="LINE">
<xsl:applytemplates/><br/>
</xsl:template>
</xsl:transform>
HTML XSLT
, ,
:
<html>
<body>
<h1> 1. . .</h1>
<h2> : , </h2>
<i> </i>
<p>
<b></b><br>
. , .
, .<br>
</p>
<p>
<b></b><br>
. .
, .<br>
</p>
</body>
</html>
,
,
,
,
. ,
,
, , .
, , <>
<> <> ,
. :
<xsl:template match="">
. . .
<xsl:applytemplates select=""/>
. . .
</xsl:template>
<xsl:template match="[1]">
. . .
189
xsl:apply5templates
</xsl:template>
<xsl:template match="">
. . .
</xsl:template>
,
.
<xsl:template> . 349,
[1] , .
, , ,
:
<xsl:template match="">
. . .
<xsl:applytemplates select="[1]" mode=""/>
<xsl:applytemplates select="[position() > 1]" mode=""/>
. . .
</xsl:template>
<xsl:template match="" mode="">
. . .
</xsl:template>
<xsl:template match="" mode="">
. . .
</xsl:template>
, ,
<xsl:foreach> <xsl:calltemplate>, ,
,
<xsl:applytemplates>.
, ,
, . ,
,
, , ,
, ,
,
.
<xsl:applytemplates/>
.
<xsl:applytemplates select="para"/>
<para>,
.
190
4. XSLT
<xsl:applytemplates select="//*"
mode=""/>
<xsl:applytemplates select="para">
<xsl:withparam name=""
select="$n+4"/>
</xsl:applytemplates>
<para>,
,
$n 4.
<xsl:applytemplates select="//">
<xsl:sort select="@isbn"/>
</xsl:applytemplates>
<>
,
isbn.
.
<xsl:foreach> . 248
<xsl:template> . 349
<xsl:withparam> . 383
xsl:attribute
<xsl:attribute>
. ,
, ,
.
XSLT, 7.1.3
<xsl:attribute> ,
<xsl:attributeset>.
name
, ,
namespace
, URI
URI
xsl:attribute
191
<xsl:attribute>
<xsl:attributeset>.
name, namespace
: ,
, <xsl:attribute name="{$chosenName}"/>.
3.
<xsl:attribute>
.
<xsl:element> <xsl:copy>
. ,
( , ,
). <xsl:attribute>
, , :
<table>
<xsl:attribute border="2"/>
</table>
, :
<table>
<xsl:calltemplate name="setborder"/>
</table>
setborder.
,
,
. XSLT
,
XML, . ,
,
.
<xsl:attribute>
( ,
URI ),
. :
,
.
<xsl:attributeset> . 198.
192
4. XSLT
name.
,
XML
. ,
, .
,
, name.
, .
namespace
XML 2.
namespace <xsl:attribute> URI
.
XSLT , <xsl:attribu
te> ,
xmlns xmlns:*.
,
, .
<xsl:attribute> namespace, (
) URI,
.
URI,
.
,
, ,
.
, ,
URI ;
xmlns. ,
.
, ,
,
URI .
,
. ,
: name()
, URI
.
namespace:
,
,
. URI URI ,
.
xsl:attribute
193
,
. (
xmlns="uri") .
namespace, ,
URI .
. name
.
namespace, ,
URI
namespace. URI ,
, name, (
).
, XSLT
. , :
<table>
<xsl:attribute name="width" namespace="http://acme.org/">
<xsl:text>200</xsl:text>
</xsl:attribute>
</table>
:
<table ns0001:width="100" xmlns:ns0001="http://acme.org"/>
,
.
,
(, ), .
, , .
, WDxsl Microsoft,
<xsl:attribute>, .
XSLT
. .
,
.
,
, ,
, :
<body bgcolor="#{@red}{@green}{@blue}">
194
4. XSLT
.
3.
<xsl:attribute> ,
.
:
<xsl:element>
<xsl:copy> ( )
,
,
<xsl:attributeset>
,
<xsl:copy> <xsl:copyof>. ,
, ,
, .
<xsl:copy> ,
. , ,
, <xsl:copy>, ,
, , <
> <>,
:
<xsl:template match="">
<>
<xsl:applytemplates select="@*"/>
</>
</xsl:template>
<xsl:template match="/@ | /@ | /@">
<xsl:copy/>
</xsl:template>
<xsl:template match="/@ | /@"/>
<>
<xsl:applytemplates>.
, ,
, .
,
<xsl:copyof>:
<xsl:template match="">
<>
xsl:attribute
195
select ,
, , <xsl:copyof>
. |, 5,
.
,
: <xsl:copyof select="@*"/>.
, ,
, , :
<xsl:copyof select=@* [not(name() = '' or name()='')]"/>
,
, name()
.
not(self::), ,
self:: ,
. localname(), namespa
ceuri().
:
.xml.
<?xml version="1.0"?>
<>
< =""/>
< =""/>
< =""/>
< =""/>
< =""/>
< =" " =""/>
< =""/>
</>
options.xsl.
196
4. XSLT
,
, 3. HTML,
, XML
="", selected.
<html version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body>
<h1> :</h1>
<select id="country">
<xsl:foreach select="//">
<option value="{@}">
<xsl:if test="@=''">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:valueof select="@"/>
</option>
</xsl:foreach>
</select>
<hr/>
</body>
</html>
( ) :
. 4.1.
<>
$.
,
.
:
.
xsl:attribute
197
conditional.xsl.
,
, .
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="" select="4.0"/>
<xsl:template match="/">
<>
<xsl:variable name="attname">
<xsl:choose>
<xsl:when test="$ < 3.0"></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:attribute name="{$attname}">17</xsl:attribute>
</>
</xsl:template>
</xsl:stylesheet>
:
< ="17"/>
,
2.0, :
< ="17"/>
, ,
<xsl:attribute>
<xsl:choose>; ,
<xsl:attribute> ,
17.
,
<xsl:attribute>, .
id <> :
<>
<xsl:attribute name="">
<xsl:foreach select="">
<xsl:valueof select="@id"/>
<xsl:if test="not(position()=last())">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:foreach>
198
4. XSLT
</xsl:attribute>
</>
.
<xsl:element> . 237
<xsl:copy> . 217
<xsl:copyof> . 221
xsl:attributeset
<xsl:attributeset> XSLT ,
.
,
.
,
CSS.
XSLT, 7.1.4
<xsl:attributeset> ,
<xsl:stylesheet>.
name
useattributesets
,
,
<xsl:attribute>.
xsl:attribute5set
199
name .
,
. ,
, ,
, , , URI
. :
,
.
useattributesets .
. ,
,
,
. :
<xsl:attributeset name=""
useattributesets=" "/>
<xsl:attributeset name="">
<xsl:attribute name="fontname">Verdana</xsl:attribute>
<xsl:attribute name="fontsize">6pt</xsl:attribute>
</xsl:attributeset>
<xsl:attributeset name="">
<xsl:attribute name="bgcolor">#xBBBBBB</xsl:attribute>
</xsl:attributeset>
<xsl:attributeset name="">
<xsl:attribute name="align">center</xsl:attribute>
</xsl:attributeset>
: A B, B
A. :
<xsl:attribute>, , ,
<xsl:attribute>, <xsl:attributeset>.
,
. ,
. <xsl:import>
. 256. , XSLT
: ,
, . (,
,
.)
, ,
. <xsl:attributeset> <xsl:copy>
useattributesets xsl:useattributesets
200
4. XSLT
, ,
<xsl:attribute>.
, ,
XSLT 1.0 .
.
, :
<xsl:attributeset name="B" useattributesets="A1 A2">
<xsl:attribute name="p">percy</xsl:attribute>
<xsl:attribute name="q">queenie</xsl:attribute>
<xsl:attribute name="r">rory</xsl:attribute>
</xsl:attributeset>
A1,
( ),
B.
A2.
. , A1,
A2. ,
A2 A1.
, B ,
,
B. A1
A2 <xsl:attribute>,
B .
B , A1 A2,
, p, q r, A1 A2
p, q r, , B
(percy, queenie rory).
: , ,
( ,
, ), .
, :
, .
:
,
.
, ,
, ,
, , ,
.
xsl:attribute5set
201
, , ,
.
useattributesets <xsl:element> <xsl:copy>,
xsl:useattributesets , , ,
useattributesets <xsl:attributeset>.
. ,
,
, ,
.
. ,
,
, , ,
, XSLT
<xsl:calltemplate> <xsl:applytemplates>.
,
<xsl:variable> . 333, , ,
. ,
:
.
. , ,
(.) ,
.
.
:
, XML,
, , <>
< ="3" ="18">.
.xml (
):
<?xml version="1.0"?>
<>
<> </>
<>1912</>
202
4. XSLT
<>Song</>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
</>
.xsl ,
<>, :
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:stripspace elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="*">
<xsl:copy>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
<xsl:template match="">
<xsl:copy useattributesets="">
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
<xsl:attributeset name="">
<xsl:attribute name=""><xsl:valueof
select="position()"/></xsl:attribute>
<xsl:attribute name=""><xsl:valueof
select="last()"/></xsl:attribute>
</xsl:attributeset>
</xsl:transform>
( ) :
<>
<> </>
<>1912</>
<>Song</>
<>
< ="1" ="4">And suddenly the wind comes soft,</>
< ="2" ="4">And Spring is here again;</>
< ="3" ="4">And the hawthorn quickens with buds
of green</>
< ="4" ="4">And my heart with buds of pain.</>
</>
</>
xsl:attribute5set
203
HTML
<table>:
<xsl:attributeset name="">
<xsl:attribute name="border">1</xsl:attribute>
<xsl:attribute name="cellpadding">3</xsl:attribute>
<xsl:attribute name="cellspacing">0</xsl:attribute>
<xsl:attribute name="width">100%</xsl:attribute>
</xsl:attributeset>
:
<table xsl:useattributesets="">
<tr></tr>
</table>
:
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr></tr>
</table>
,
, :
<table border="2" rules="cols" xsl:useattributesets="">
<tr></tr>
</table>
:
<table border="2" rules="cols" cellpadding="3" cellspacing="0" width="100%">
<tr></tr>
</table>
,
:
<xsl:attributeset name=""
useattributeset="">
<xsl:attribute name="border">2</xsl:attribute>
<xsl:attribute name="rules">cols</xsl:attribute>
</xsl:attributeset>
, <xsl:element>
<xsl:copy>.
204
4. XSLT
.
<xsl:element> . 237
<xsl:copy> . 217
3
xsl:calltemplate
<xsl:calltemplate>
.
.
XSLT, 6
<xsl:calltemplate name=>
<xsl:withparam> *
</xsl:calltemplate>
<xsl:calltemplate> ; .
name
<xsl:withparam>.
,
.
name ,
name <xsl:template> .
, ,
URI . , URI
( ).
<xsl:template> , .
xsl:call5template
205
<xsl:template>
,
,
.
. <xsl:import> . 256.
name.
.
,
,
<xsl:choose>.
<xsl:withparam>
<xsl:param> <xsl:template>, <xsl:withparam>
( , <xsl:variable>),
<xsl:param>
.
<xsl:withparam>,
<xsl:param> <xsl:template>,
. .
<xsl:template> <xsl:param>,
<xsl:withparam> <xsl:call
template>, <xsl:param> .
. <xsl:param> . 316. .
<xsl:template> ;
,
, .
(,
<xsl:applyimports>, . 174).
<xsl:calltemplate>
, ,
.
.
<xsl:call
template>. <xsl:calltemplate> <xsl:variable>,
206
4. XSLT
,
, (,
<xsl:valueof>), .
, ,
, , .
, ,
:
<xsl:template name="">
<xsl:param name=""/>
<xsl:valueof select="concat('(',$,')')"/>
</xsl:template>
:
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="@"/>
</xsl:calltemplate>
</xsl:variable>
120.00,
$ (120.00). ,
, ,
, (120.00);
,
.
<xsl:calltemplate> ,
, <xsl:calltemplate>
<xsl:foreach>. :
, <xsl:applytemplates>
.
, , ,
( , ).
:
<xsl:template name="" mode="" match="node()">
<xsl:valueof select="count(ancestor::node())"/>
</xsl:template>
, ,
,
, .
.
<xsl:calltemplate>:
<xsl:variable name="">
<xsl:foreach select="following::node()[1]">
xsl:call5template
207
<xsl:calltemplate name=""/>
</xsl:foreach>
</xsl:variable>
<xsl:applytemplates> :
<xsl:variable name="">
<xsl:applytemplates select="following::node()[1]" mode=""/>
</xsl:variable>
$ ,
,
. ,
,
,
. ,
: <xsl:if test="$ > 4">.
:
.
XSLT ,
,
for while, ,
, .
XSLT .
:
( L) {
((L)) {
((L));
((L));
}
}
, ;
,
, , .
, .
:
, . ,
; , 9 10,
.
:
. XPath 1.0
,
208
4. XSLT
max() min(),
,
. ,
, , .
:
, ,
, .
XPath: , [1]
, [position()!=1] .
,
.
scene.xml . :
<?xml version="1.0"?>
<SCENE><TITLE> I. . .</TITLE>
<STAGEDIR> </STAGEDIR>
<SPEECH>
<SPEAKER></SPEAKER>
<LINE> . , .</LINE>
<LINE> , .</LINE>
</SPEECH>
<SPEECH>
<SPEAKER></SPEAKER>
<LINE> . .</LINE>
<LINE> , .</LINE>
</SPEECH>
..
</SCENE>
.xsl.
max.
, .
, ,
(<xsl:when test="$">). , $
<LINE>
. ,
, ,
.
,
, . , ,
.
xsl:call5template
209
max,
<SPEECH>.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template name="max">
<xsl:param name=""/>
<xsl:choose>
<xsl:when test="$">
<xsl:variable name="" select="count($[1]/LINE)"/>
<xsl:variable name="">
<xsl:calltemplate name="max">
<xsl:withparam name="" select="$[position()!=1]"/>
</xsl:calltemplate>
</xsl:variable>
<xsl:choose>
<xsl:when test="$ > $">
<xsl:valueof select="$"/>
</xsl:when>
<xsl:otherwise>
<xsl:valueof select="$"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
: <xsl:text/>
<xsl:calltemplate name="max">
<xsl:withparam name="" select="//SPEECH"/>
</xsl:calltemplate>
<xsl:text/> .
</xsl:template>
</xsl:transform>
,
:
<?xml version="1.0" encoding="utf8" ?>
: 20 .
, ,
.
. :
<xsl:variable name="">
<xsl:foreach select="SPEECH">
210
4. XSLT
<xsl:sort select="count(LINE)"/>
<xsl:if test="position()=last()">
<xsl:valueof select="count(LINE)"/>
</xsl:if>
</xsl:foreach>
</xsl:variable>
,
,
,
. ,
, .
, , ,
, .
, ,
normalizespace() ,
.
:
scene.xml,
, .
:
<LINE> . , .</LINE>
,
,
. .
: ,
,
.
scene.xml , .
.xsl
, <SPEAKER> :
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="" select="//SPEAKER"/>
.
. , ,
translate() ,
, normalizespace()
xsl:call5template
211
concat()
. ( 7.)
, substringbefore(),
.
$ , .
(
substringafter()), .
, .
<xsl:template name="">
<xsl:param name=""/>
<xsl:variable name="1"
select="translate($,
'.,:?!;',
'
')"/>
<xsl:variable name="2"
select="concat(normalizespace($1), ' ')"/>
<xsl:variable name="" select="substringbefore($2,' ')"/>
<xsl:choose>
<xsl:when test="$">
<xsl:choose>
<xsl:when test="$[.=$]"></xsl:when>
<xsl:otherwise>
<xsl:variable name="" select="substringafter($2,' ')"/>
<xsl:calltemplate name="">
<xsl:withparam name="" select="$"/>
</xsl:calltemplate>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>
,
.
<LINE> , ,
:
<xsl:template match="/">
<xsl:foreach select="//LINE">
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="."/>
</xsl:calltemplate>
</xsl:variable>
<xsl:if test="$=''">
<xsl:copyof select="."/>;
</xsl:if>
212
4. XSLT
</xsl:foreach>
</xsl:template>
</xsl:transform>
<LINE>,
(<SPEAKER>), :
<?xml version="1.0" encoding="UTF8"?>
<LINE> . , .</LINE>;
<LINE> . </LINE>;
<LINE> , , ,</LINE>;
<LINE>! , !</LINE>;
<LINE>, ! !</LINE>;
<LINE> .</LINE>;
<LINE>, .</LINE>;
<LINE>, , ?</LINE>;
<LINE>, , </LINE>;
<LINE> , .</LINE>;
, ,
( substringbefore() ,
). normali
zespace() concat().
, ,
,
, .
, ,
. , ,
. ,
, , ,
, .
<xsl:template name="">
<xsl:param name=""/>
<xsl:if test="$ != 0">
<td> </td>
<xsl:calltemplate name="">
<xsl:withparam name="" select="$ 1"/>
</xsl:calltemplate>
</xsl:if>
</xsl:template>
,
, , :
<xsl:calltemplate name="">
<xsl:withparam name="" select="4"/>
</xsl:calltemplate>
xsl:choose
213
.
<xsl:applytemplates> . 178
<xsl:param> . 316
<xsl:withparam> . 383
xsl:choose
<xsl:choose> .
,
ifthenelse ; , ,
switch select.
XSLT, 9.2
<xsl:choose>
<xsl:when> +
<xsl:otherwise> ?
</xsl:choose>
<xsl:choose> ; .
<xsl:when>.
<xsl:otherwise>, ,
.
<xsl:choose> :
<xsl:when>, test .
<xsl:when> ,
test.
<xsl:when> test
, <xsl:otherwise>. <xsl:otherwi
se> , , <xsl:choose>
.
( )
. ,
214
4. XSLT
, <xsl:choose>
.
, test <xsl:when>,
,
, ,
, .
<xsl:choose> ,
.
ifthenelse, switch Select Case,
.
<xsl:choose> <xsl:when>
<xsl:otherwise> <xsl:if>.
<xsl:if> ,
, else.
<xsl:choose> <xsl:variable> (
<xsl:param>, <xsl:withparam>),
:
. , ,
.
. ,
.
<xsl:choose>
<xsl:when test="='AZ'"></xsl:when>
<xsl:when test="='CA'"></xsl:when>
<xsl:when test="='DC'"> </xsl:when>
......
<xsl:otherwise><xsl:valueof select=""/></xsl:otherwise>
</xsl:choose>
, ,
100.
<xsl:variable name="">
<xsl:choose>
<xsl:when test="@">
<xsl:valueof select="@"/>
</xsl:when>
<xsl:otherwise>100</xsl:otherwise>
</xsl:choose>
xsl:comment
215
</xsl:variable>
: :
<!>
<xsl:choose>
<xsl:when test="@">
<xsl:variable name="">
<xsl:valueof select="@"/>
</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="" select="100"/>
</xsl:otherwise>
</xsl:choose>
<!>
XSLT, .
, ,
,
<xsl:choose>.
.
<xsl:when> . 381
<xsl:otherwise> . 302
<xsl:if> . 253
xsl:comment
<xsl:comment>
.
XSLT, 7.4
<xsl:comment>
</xsl:comment>
<xsl:comment> , .
216
4. XSLT
, <xsl:comment>,
, , ,
, . XSLT
, .
,
XML. , XSLT
,
, .
, .
XML HTML :
<! >
, ,
. ,
,
.
.
<xsl:template>
<xsl:comment>,
.
HTML
,
HTML. , ,
, , .
.
xsl:copy
217
, ,
, .
8.
.
<xsl:if test="functionavailable(Date:toString)" xmlns:Date="java:java.util.Date">
<xsl:comment>:
<xsl:valueof select="Date:toString()"/>
</xsl:comment>
</xsl:if>
:
<!: Tue Dec 07 23:38:08 GMT 1999>
JavaScript HTML:
<script language="JavaScript">
<xsl:comment>
function bk(n) {
parent.frames['content'].location="chap" + n + ".1.html";
}
//</xsl:comment>
</script>
:
<script language="JavaScript">
<!
function bk(n) {
parent.frames['content'].location="chap" + n + ".1.html";
}
//>
</script>
,
XSLT .
.
.
functionavailable() 7.
xsl:copy
<xsl:copy>
. ;
,
218
4. XSLT
( ) .
<xsl:copyof>, . . 221.
XSLT, 7.5
<xsl:copy useattributesets=>
</xsl:copy>
<xsl:copy> , .
useattributesets , ,
,
, ,
.
(
,
). useattributesets .
<xsl:copy> ,
.
,
<xsl:element>. ,
. ,
, .
useattributesets :
, ,
.
219
xsl:copy
.
.
, .
useattributesets .
,
<xsl:attribute>. ,
.
,
, .
,
. useattributesets
. , , URI
,
, (,
, ,
, URI ).
,
, ,
,
URI
, , .
( ,
XML),
. useattributesets .
,
. useattributesets .
.
(
URI),
.
, ,
:
, ,
, .
,
, ,
. ,
, URI ,
,
220
4. XSLT
URI
.
URI,
.
<xsl:copy> , ,
XML XML,
. , XML
XHTML, ,
HTML <i> <b>,
HTML .
<xsl:copy> ,
, .
, :
<xsl:template match="@*|node()" mode="">
<xsl:copy>
<xsl:applytemplates select="@*" mode=""/>
<xsl:applytemplates mode=""/>
</xsl:copy>
</xsl:template>
,
, @*
, node()
child::node() ,
.
, , ,
, . ,
mode="",
.
<xsl:copyof>. <xsl:copy>
, .
,
HTML ,
.
<xsl:template match=" table | tbody | tr | th | td ">
<xsl:copy>
xsl:copy5of
221
<xsl:foreach select="@*">
<xsl:copy/>
</xsl:foreach>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
,
, ;
, ,
,
.
<xsl:copyof>:
<xsl:template match=" table | tbody | tr | th | td ">
<xsl:copy>
<xsl:copyof select="@*"/>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
, SVG,
. SVG
. (SVG Scalable Vec
tor Graphics, . XML,
.
.)
<xsl:template match="svg:*" xmlns:svg="http://www.w3.org/2000/svg">
<xsl:copy>
<xsl:copyof select="@*">
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
.
<xsl:copyof> ().
xsl:copyof
<xsl:copyof>
. : ,
.
222
4. XSLT
XSLT, 11.3
<xsl:copyof> , .
select
; .
select ,
,
. :
, .
select ,
,
. (
),
,
.
,
disableoutputescaping="yes" ( <xsl:text> <xsl:valueof>),
,
, ,
.
(,
), <xsl:copyof> , <xsl:valueof>.
,
string(),
.
xsl:copy5of
223
<xsl:copyof> :
,
,
.
<xsl:copyof>
, ,
. ,
, .
,
, .
: <xsl:copyof>
.xml
, 1998 .
<?xml version="1.0"?>
< ="A">
<>
<>10Jun98</>
< ="2"></>
< ="1"></>
</>
<>
<>10Jun98</>
< ="2"></>
< ="2"></>
</>
<>
<>16Jun98</>
< ="1"></>
< ="1"></>
</>
<>
<>16Jun98</>
< ="3"></>
< ="0"></>
</>
<>
<>23Jun98</>
< ="1"></>
< ="2"></>
</>
224
4. XSLT
<>
<>23Jun98</>
< ="0"></>
< ="3"></>
</>
</>
.xsl.
HTML ,
, , ,
<xsl:copyof>.
, ,
. ,
,
.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="">
<tr>
<td><b></b></td>
<td><b></b></td>
<td><b></b></td>
<td><b></b></td>
</tr>
</xsl:variable>
<xsl:template match="/">
<html><body>
<h1> <xsl:valueof select="/*/@"/></h1>
<xsl:foreach select="//">
<h2><xsl:valueof select="concat([1], ' ', [2])"/></h2>
<table bgcolor="#cccccc" border="1" cellpadding="5">
<xsl:copyof select="$"/>
<tr>
<td><xsl:valueof select=""/> </td>
<td><xsl:valueof select="[1]"/> </td>
<td><xsl:valueof select="[2]"/> </td>
<td><xsl:valueof
select="concat([1]/@, '', [2]/@)"/> </td>
</tr>
</table>
</xsl:foreach>
</body></html>
</xsl:template>
</xsl:stylesheet>
( , ,
,
. !)
225
xsl:copy5of
. 4.2.
XSLT 1.0 ( ;
XSLT 1.1)
. :
, <xsl:copyof>,
. XSLT 1.0
,
,
. XSLT 1.1 ,
, .
XSLT 1.1 ,
.
<xsl:copyof>,
XSLT,
. <xsl:copyof> ,
, <xsl:copy>,
, .
, XML, ,
, <>, XHTML.
HTML
:
<xsl:template match="">
<div>
<xsl:copyof select="node()">
</div>
</xsl:template>
226
4. XSLT
, <xsl:copy>,
: <>
.
<xsl:copyof select="@*"/>
.
:
<xsl:copyof select="@ | @ | @"/>
, ,
. , generate
id(), 7:
<xsl:variable name="" select="generateid(@)"/>
<xsl:copyof select="@*[generateid() != $]"/>
.
<xsl:copy> . 217
<xsl:variable> . 370
xsl:decimalformat
<xsl:decimalformat>
,
formatnumber().
, <xsl:decimalformat>
formatnumber(). , <xsl:number>
,
, string(), ,
<xsl:valueof> .
XSLT, 12.3
<xsl:decimalformat
name=
decimalseparator=
groupingseparator=
infinity=
minussign=
NaN=
227
xsl:decimal5format
percent=
permille=
zerodigit=
digit=
patternseparator= />
<xsl:decimalformat> .
,
<xsl:stylesheet>.
name
. ,
,
.
decimalseparator
,
.
..
groupingseparator
, .
,.
infinity
,
. Infinity.
minussign
, .
.
NaN
,
(NaN). NaN.
percent
,
. %.
permille
,
. .
zerodigit
,
,
, .
0.
digit
,
, ,
. #.
patternseparator
, ,
.
;.
228
4. XSLT
; .
name , <xsl:decimalformat>
;
.
formatnumber(),
( );
, formatnumber()
.
, <xsl:decimalformat>
, ,
,
( ). ,
<xsl:decimalformat>
.
<xsl:decimalformat>
. ,
.
,
formatnumber(),
, , .
,
.
, <xsl:decimalformat>:
<xsl:decimalformat name=""
decimalseparator=","
groupingseparator="." >
:
formatnumber(1234.5, '#.##0,00', '')
:
1.234,50
. , ,
<xsl:decimalformat>,
.
formatnumber()
7.
:
<xsl:decimalformat>. :
229
xsl:decimal5format
decimalseparator
groupingseparator
percent
permille
zerodigit
digit
patternseparator
<xsl:decimalformat> ,
, , .
, , .
:
decimalseparator
groupingseparator
infinity
minussign
NaN
percent
permille
zerodigit
, <xsl:decimalformat>
***, formatnumber(1 div 0, $format)
***, .
<xsl:decimalformat> formatnumber()
.
, , ,
, ,
, .
, <xsl:number>,
, .
<xsl:decimalformat>
, ,
,
, ,
.
,
<xsl:decimalformat> .
230
4. XSLT
1
;
,
, ,
.
, XSLT.
,
formatnumber(). ,
formatnumber().
, , :
# , , ,
0 , ,
% ,
; ,
, ,
<xsl:decimalformat decimalseparator="," groupingseparator="."/>
1234.5
#.##0,00
1.234,50
123.456
#.##0,00
123,46
1000000
#.##0,00
1.000.000,00
59
#.##0,00
59,00
1 div 0
#.##0,00
Infinity
1234
###0,0###
1234,0
1234.5
###0,0###
1234,5
.00035
###0,0###
0,0004
0.25
#00%
25%
0.736
#00%
74%
#00%
100%
42
#00%
4200%
3.12
#,00;(#,00)
(3,12)
3.12
#,00;#,00CR
3,12CR
231
xsl:document
2
, ,
09.
, .
, :
<xsl:decimalformat zerodigit="a" minussign="~"/>
10
aa
ba
12.34
##.##
bc.de
9999999
#,###,###
~j,jjj,jjj
3
,
, .
<xsl:decimalformat NaN=" " infinity=" "/>
'a'
1 div 0
.
formatnumber() 7.
<xsl:number> . 288.
xsl:document
<xsl:document>
. ,
XSLT 1.1,
XSLT 1.0.
,
, XML
XML HTML, ,
.
XSLT 1.1, 16.5
232
4. XSLT
<xsl:document
href= { uri }
method= { "xml" | "html" | "text" | }
version= { NMtoken }
encoding= { }
omitxmldeclaration= { "yes" | "no" }
standalone= { "yes" | "no" }
doctypepublic= { }
doctypesystem= { }
cdatasectionelements= { }
indent= { "yes" | "no" }
mediatype= { } >
</xsl:document>
<xsl:document> ,
.
href, <xsl:document>
<xsl:output>, . 303.
,
.
<xsl:document>
, XPath
.
.
href
,
URI
method
xml |
html |
text |
version
NMtoken
encoding
233
xsl:document
omitxmldeclaration yes | no
,
XML
standalone
yes | no
, standalone
,
doctypepublic
,
DOCTYPE
doctypesystem
,
DOCTYPE
cdatasectionele
ments
,
,
CDATA
indent
yes | no
,
,
mediatype
(
MIME),
<xsl:document> .
<xsl:document> <xsl:fallback>.
<xsl:fallback> ,
XSLT 1.0,
<xsl:document>. , ,
,
version="1.1" <xsl:stylesheet>
xsl:version="1.1" .
<xsl:document>,
,
, <xsl:document>.
.
,
<xsl:document> ,
<xsl:output> .
234
4. XSLT
href.
URI, ,
URI. ( , XSLT
,
URI. URI,
, URI, file:/,
, .
, URI, ,
, ftp: webdav:, ,
.)
URI, ,
URI URI
.
,
.
, ,
, ,
, <xsl:document> ,
.
. URI
, API,
.
file:/c:/results/index.html, ,
<xsl:document href="chapter1.html">,
file:/c:/results/chapter1.html.
<xsl:document>,
,
<xsl:document>.
HTML, ,
. URI href
,
<xsl:document>.
<xsl:document> ,
,
, <xsl:document>,
. , :
<xsl:variable name="">
<xsl:document href="chap{$nr}.html" method="html">
<xsl:applytemplates select=""/>
</xsl:document>
</xsl:variable>
xsl:document
235
;
, .
,
, <xsl:copyof>
. ,
,
href
, .
, <xsl:copyof>
. ,
,
. ,
,
URI
.
. ,
, XML,
,
. ,
, : ,
. HTML
, :
XML XML,
HTML.
.
. ,
( document(),
7)
.
,
, .
236
4. XSLT
:
,
.
,
.
.xml. :
<>
<>Rupert Brooke</>
<>1912</>
<>Song</>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
<>
<>My heart all Winter lay so numb,</>
<>The earth so dead and frore,</>
. . .
.xsl.
,
<>
<xsl:document>. ,
.
<xsl:variable>, ,
, ,
.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
<xsl:template match="">
<>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:applytemplates select=""/>
</>
</xsl:template>
<xsl:template match="">
<xsl:variable name="" select="concat('', position(), '.xml')"/>
< ="{position()}" href="{$}"/>
xsl:element
237
<xsl:document href="{$}">
<xsl:copyof select="."/>
</xsl:document>
</xsl:template>
</xsl:stylesheet>
( , ):
<?xml version="1.0" encoding="utf8" ?>
<>
<>Song</>
<>Rupert Brooke</>
<>1912</>
< ="1" href="1.xml"/>
< ="2" href="2.xml"/>
< ="3" href="3.xml"/>
</>
, elementava
ilable() , <xsl:document>,
, . ele
mentavailable() 7.
.
<xsl:output> . 303
xsl:element
<xsl:element>
.
,
.
238
4. XSLT
XSLT, 7.1.2
<xsl:element> .
name
, ,
namespace
, URI
URI
useattributesets
,
, ,
name namespace.
useattributesets, ,
<xsl:attribute> <xsl:copy>, <xsl:copyof>:
, .
, <xsl:attribute>
<xsl:copy>, <xsl:copyof>, ,
useattributesets.
.
XSLT .
,
xsl:element
239
<xsl:element> XML,
<xsl:element>
,
. ,
,
, ,
<xsl:element>.
3.
name namespace
; ,
.
name.
;
XML .
fo:block. ,
,
; namespace,
, .
, XSLT
,
, , , .
.
,
, name.
2,
XML Namespaces. , ,
,
,
URI .
<xsl:element> namespace,
( ):
, URI
.
URI,
.
, . XSLT
,
URI,
. XSLT
240
4. XSLT
, URI
.
,
, XSLT
, URI.
, ,
, URI .
namespace:
,
, :
, xmlns:prefix
<xsl:element>, .
URI URI ,
.
,
. , xmlns=
"uri" . ,
XSLT,
, , :
URI .
,
,
.
, ,
,
, .
, ,
XPath, : <xsl:for
each select="namespace::*">. ,
, XML.
useattributesets,
, ,
<xsl:attributeset> .
.
, ,
, .
<xsl:attribute>.
<xsl:attribute> <xsl:element>,
xsl:element
241
; , , <xsl:call
template>. ,
( ),
.
,
XML,
. ,
.
, ,
, .
,
, ,
, <xsl:element>.
,
<xsl:copy>.
, <xsl:element> ,
.
<xsl:element>
, .
URI ,
.
,
,
.
:
.xml <>
:
<?xml version="1.0"?>
< =" "
=" (Michel BeaudouinLafon)"
=" (Jack Howlett)"
="Chapman & Hall"
isbn="0 412 55800 9"
="1994"/>
242
4. XSLT
.xsl <>,
.
:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="">
<>
<xsl:foreach select="@*">
<xsl:element name="{name()}">
<xsl:valueof select="."/>
</xsl:element>
</xsl:foreach>
</>
</xsl:template>
</xsl:transform>
<> ( @*),
, ,
, .
XML ( Saxon) .
.
, . ,
<xsl:foreach>
,
.
<>
<> (Michel BeaudouinLafon)</>
<>1994</>
<isbn>0 412 55800 9</isbn>
<>Chapman & Hall</>
<>Objectoriented Languages</>
<> (Jack Howlett)</>
</>
.
<xsl:attribute> . 190
<xsl:copy> . 217
3
xsl:fallback
243
xsl:fallback
<xsl:fallback> ,
,
.
XSLT, 15
<xsl:fallback>
</xsl:fallback>
<xsl:fallback> , .
<xsl:fallback> :
, XSLT,
, ,
, XSLT,
(, 1.0). ,
XSLT 1.1 , <xsl:document>.
<xsl:document>
, XSLT 1.0,
,
, <xsl:fallback>.
, ,
, ,
, ,
XSLT,
.
<xsl:fallback> ,
, .
244
4. XSLT
XSLT ,
, :
XSLT
,
:
extensionelementprefixes <xsl:stylesheet>
xsl:extensionelementprefixes
, ,
, XSLT , ,
. , ,
XSLT. ,
, ,
, ,
.
, XSLT,
, XSLT 1.0, :
XSLT
1.0, .
, .
xsl:fallback
245
<xsl:fallback> ,
XSLT,
XSLT.
HTML , , ,
. XSLT
, ,
.
, , XSLT
( )
, .
; ,
. <xsl:fallback> ,
, XSLT
, . , :
, ,
,
,
, ,
elementavailable() ( 7),
.
, .
1:
XSLT
,
XSLT 6.1.
, URI, (
, ,
246
4. XSLT
XSLT 1.0).
,
.
<xsl:template match="">
<div id="" xsl:version="6.1">
<xsl:copytooutput href=".xhtml">
<xsl:fallback>
<xsl:copyof select="document('.xhtml')"/>
</xsl:fallback>
</xsl:copytooutput>
</div>
</xsl:template>
2: ,
,
, , ,
, ,
, .
, XSLT 1.0 ( xt, Saxon Xalan)
. XSLT 1.1
,
. ,
XSLT 1.1, ,
,
:
<xsl:template match="">
<a href=".html" xsl:version="1.1"
xmlns:saxon="http://icl.com/saxon"
xmlns:xt="http://www.jclark.com/xt"
xmlns:xalan="com.lotus.xsl.extensions.Redirect"
xsl:extensionelementprefixes="saxon xt xalan">
<xsl:document href=".html">
<xsl:calltemplate name=""/>
<xsl:fallback>
<saxon:output file=".html">
<xsl:calltemplate name=""/>
<xsl:fallback/>
</saxon:output>
<xt:document href=".html">
<xsl:calltemplate name=""/>
<xsl:fallback/>
</xt:document>
<xalan:write file=".html">
<xsl:calltemplate name=""/>
xsl:fallback
247
<xsl:fallback/>
</xalan:write>
</xsl:fallback>
</xsl:document>
</a>
</xsl:template>
, ,
XSLT 1.1 .
, ,
.
3:
<xsl:fallback>; ,
.
, XSLT 1.1,
, ,
, , XPath
<xsl:foreach>. ,
XSLT 1.1, XSLT 1.0 :
<xsl:variable name="">
< ="AZ" =""/>
< ="CA" =""/>
< ="NY" =""/>
</xsl:variable>
. . .
<xsl:valueof select="$/[@='CA']/@"/>
XSLT 1.1,
<xsl:fallback>, ,
XSLT 1.0: ,
.
XSLT,
systemproperty().
XSLT 1.0, XSLT 1.1.
, .
, 1.1,
, . XSLT 1.0
, document(''),
.
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="">
< ="AZ" =""/>
< ="CA" =""/>
< ="NY" =""/>
</xsl:variable>
248
4. XSLT
<xsl:stylesheet> version="1.1",
version="1.0",
, ,
, 1.0,
,
. XSLT 1.0
,
, version="1.0" version="1.1", , ,
XSLT 1.0, , .
document(), XSLT 1.0.
, Micro
soft msxml:nodeset().
.
.
3
3
elementavailable() 7
systemproperty() 7
xsl:foreach
<xsl:foreach>, XPath,
.
249
xsl:for5each
XSLT, 8
<xsl:foreach select=>
<xsl:sort> *
</xsl:foreach>
<xsl:foreach> , .
select
, ,
<xsl:sort>, .
<xsl:foreach> ,
, .
, .
select
select . ,
. XPath,
5, .
(, )
,
, .
, ,
document() ( 7)
XML.
, <xsl:foreach>,
.
( ); position()
(
position()=1, ), last()
.
250
4. XSLT
, ,
<xsl:foreach> . , ,
, :
<xsl:foreach select="para">
<p><xsl:valueof select="para"/></p>
</xsl:foreach>
? <xsl:foreach>
<para>, <xsl:valueof>
<para>, . ,
:
<xsl:foreach select="para">
<p><xsl:valueof select="."/></p>
</xsl:foreach>
<xsl:sort>,
. ,
, ,
:
, .
, ,
.
,
( ).
<xsl:sort>,
<xsl:foreach>,
. <xsl:sort>
. . <xsl:sort>
. 330. ,
. ,
<xsl:sort> ,
, .
,
.
, , ,
( 5).
, select="precedingsibling::*"
( ), , precedingsibling
, .
,
. , "preceding
sibling::*[1]"
xsl:for5each
251
, ,
, .
, :
<xsl:sort select="position()" order="descending" datatype="number">
<xsl:foreach> .
, .
.
<xsl:foreach> .
, <xsl:applytemplates>.
. ,
<xsl:applytemplates> ( )
,
, <xsl:foreach> (
) .
,
, , , .
.
<xsl:element> . 237.
<xsl:template match="">
<>
<xsl:foreach select="@*">
<xsl:element name="{name()}">
<xsl:valueof select="."/>
</xsl:element>
</xsl:foreach>
</>
</xsl:template>
, XML
.
:
XML. ,
(
),
, .
252
4. XSLT
.
.xsl.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="*">
<xsl:comment>
<xsl:valueof select="name()"/>
<xsl:foreach select="ancestor::*">
<xsl:sort select="position()" order="descending" datatype="number"/>
<xsl:text> </xsl:text>
<xsl:valueof select="name()"/>
</xsl:foreach>
</xsl:comment>
<xsl:applytemplates/>
</xsl:template>
</xsl:transform>
:
<! >
<! _>
<! >
<! >
<! >5.95
<! _>3
<xsl:foreach>
. , key() (
7),
, ( )
, key()
, .
, :
<xsl:variable name="">
<xsl:foreach select="document('.xml')">
<xsl:valueof select="key('', $)/@"/>
</xsl:foreach>
</xsl:variable>
xsl:if
253
,
$.
<xsl:foreach> ,
document()
. ; ,
, key().
, ,
:
<xsl:variable name="" select="/"/>
,
:
<xsl:foreach select="$">
. . .
</xsl:foreach>
.
<xsl:applytemplates> . 178
<xsl:sort> . 330
document() 7
key() 7
xsl:if
<xsl:if> , ,
.
<xsl:if> if,
.
XSLT, 9.1
<xsl:if> , .
254
4. XSLT
Test
test ,
,
boolean(). ,
; .
XPath .
, :
, ,
, , . ( ,
.)
, , .
, , .
<xsl:if> ,
. if
then, .
( ifthenelse switch,
Select Case ), <xsl:if> <xsl:choose>.
<xsl:if>
. <xsl:message>.
<xsl:if>
<xsl:foreach>. ,
. :
<xsl:foreach select="para">
<xsl:if test="@display='yes'">
<p><xsl:applytemplates/></p>
</xsl:if>
</xsl:foreach>
:
<xsl:foreach select="para[@display='yes']">
<p><xsl:applytemplates/></p>
</xsl:foreach>
255
xsl:if
<hr>
<para>:
<xsl:template match="para">
<p><xsl:applytemplates/></p>
<xsl:if test="position()=last()">
<hr/>
</xsl:if>
</xsl:template>
,
0 100. ,
:
(number(@)
NaN)
100
<xsl:if test="not(@) or
(string(number(@))='NaN') or
(number(@) < 0) or
(number(@) > 100)">
<xsl:message>
"" , 0 100
.
</xsl:message>
</xsl:if>
<xsl:if>
,
.
:
.xml <>
.
<?xml version="1.0"?>
<>
<> </>
<> </>
<> </>
<> </>
<> </>
</>
256
4. XSLT
.xsl ,
.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="">
<xsl:valueof select=""/>
<xsl:foreach select="">
<xsl:valueof select="."/>
<xsl:if test="position()!=last()1 and position()!=last()">, </xsl:if>
<xsl:if test="position()=last()1"> </xsl:if>
</xsl:foreach>
</xsl:template>
</xsl:transform>
, ,
.
<xsl:choose> . 213
xsl:import
<xsl:import> ,
.
, , ,
, ,
.
XSLT, 2.6.2
<xsl:import> . ,
<xsl:stylesheet>.
<xsl:stylesheet> <xsl:import>
.
257
xsl:import
href
URI
URI ,
; .
URI, href,
. URI,
URI XML ,
<xsl:import>. , main.xsl
<xsl:import href="date.xsl"/>,
date.xsl , main.xsl. XSLT 1.1
xml:base,
URI 2.
URI URI.
URI XML,
XSLT.
,
<xsl:import>. :
, ,
<xsl:include> . .
URI, ,
URI,
URI . , ,
<xsl:import> URI
document().
( ,
,
xsl:excluderesultprefixes ),
, .
, . ,
, ,
name namespace <xsl:element>.
version, extensionelementprefixes excluderesult
prefixes,
258
4. XSLT
, xml:lang xml:space, ,
<xsl:stylesheet>
, <xsl:stylesheet> .
(
), 3.
<HTML>. ,
,
, /,
.
<xsl:include>, ,
<xsl:import>, .
.
,
, , .
. ,
,
.
. :
,
,
, ,
, ,
,
, , . 4.3,
A, C, F, B, E , , D.
<xsl:include>, <xsl:import>,
. . 4.4.
J E,
, E, E ,
C. ,
( ;
, ),
:
A
xsl:import
259
. 4.3.
( ): A, C, F, B, E, D
. 4.4. <xsl:include>.
C, E J ( D G)
, , ,
<xsl:template> E
, G.
<xsl:import>
,
, <xsl:import>
260
4. XSLT
, ,
.
, . , <xsl:import>
,
, (, )
,
, , .
.
.
<xsl:attribute
set>
, . ,
,
. ,
(
,
). XSLT
:
, .
<xsl:decimal
format>
<xsl:decimalformat>
.
<xsl:decimalformat> (
), . XSLT
.
<xsl:import>
<xsl:include>
;
.
<xsl:key>
,
. . <xsl:key>
. 272.
<xsl:namespace
alias>
,
. ,
. XSLT
: ,
.
<xsl:output>
<xsl:output> .
cdatasectionelements
CDATA,
<xsl:output>. ,
261
xsl:import
<xsl:output>,
,
. , . XSLT
:
, .
<xsl:stripspace>
<xsl:preserve
space>
<xsl:stripspace>
<xsl:preservespace>,
,
.
,
,
match <xsl:template>. ,
, prefix:*,
, , , *.
. ,
( ). XSLT
:
, .
,
.
<xsl:template>
<xsl:ap
plytemplates>
mode.
match, .
,
.
,
:
<xsl:template> . 349.
, . XSLT
:
, . (
.)
<xsl:calltemplate>
. ,
.
; XSLT
,
.
<xsl:variable>
<xsl:param>
XSLT
, ,
262
4. XSLT
. ,
<xsl:va
riable> <xsl:param>
, .
, . ,
.
,
.
. ,
,
. XSLT
.
<xsl:import> , ,
XSLT,
Java.
<xsl:import>
,
.
, <xsl:import>
,
. <xsl:import>
. , ,
,
.
,
. ,
, ,
, ,
,
. .
,
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:="http://acme.co.nz/colors"
version="1.0">
<xsl:variable name=":" select="'#0088ff'"/>
263
xsl:import
. 4.5.
<xsl:variable name=":" select="'#ff0088'"/>
<xsl:variable name=":" select="'#ff00ff'"/>
</xsl:stylesheet>
<xsl:include> ( <xsl:import>,
).
, .
, ,
.
C, ,
Z :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:="http://acme.co.nz/colors"
version="1.0">
<xsl:import href="C.xsl"/>
<xsl:variable name=":" select="'#cc00cc'"/>
</xsl:stylesheet>
(,
<xsl:stylesheet>). , Z ,
C, . ,
: ,
Z, ,
:.
:
, <xsl:include>. ,
, <xsl:import>.
264
4. XSLT
, <xsl:import>
.
1:
,
,
.
XML.
.xsl.
<?xml version="1.0" encoding="UTF8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:acme="http://acme.com/xslt"
excluderesultprefixes="acme">
<xsl:import href=".xsl"/>
<xsl:output encoding="UTF8" indent="yes"/>
<xsl:variable name="acme:" select="'Acme Widgets Limited'"/>
<xsl:template match="/">
<c><xsl:valueof select="$acme:"/></c>
</xsl:template>
</xsl:stylesheet>
.xsl.
<?xml version="1.0" encoding="UTF8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:co="http://acme.com/xslt">
<xsl:variable name="co:" select="'Acme Widgets Incorporated'"/>
<xsl:variable name="co:"
select="concat('Copyright ', $co:)"/>
</xsl:stylesheet>
:
<?xml version="1.0" encoding="UTF8" ?>
<c>Copyright Acme Widgets Limited</c>
xsl:import
265
$co:
$co:
,
, .xsl.
,
, : acme
URI , co
.xsl, .
: encoding="UTF8"
, .
ASCII,
UTF8 ASCII,
. ,
, ASCII,
,
: iso88591 ( Microsoft,
Windows ANSI, ).1
, <xsl:import>
.
2:
.xsl,
HTML,
.
import .
, 1.
.xml. :
<?xml version="1.0"?>
<>
<> </>
<>1912</>
<>Song</>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
iso88591
UTF8. . . .
266
4. XSLT
</>
..
</>
A
.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title><xsl:valueof select="//"/></title>
</head>
<body>
<xsl:applytemplates/>
</body>
</html>
</xsl:template>
<xsl:template match="">
<h1><xsl:applytemplates/></h1>
</xsl:template>
<xsl:template match="">
<div align="right">
<xsl:applytemplates/>
</div>
</xsl:template>
<xsl:template match="">
<p><xsl:applytemplates/></p>
</xsl:template>
<xsl:template match="">
<xsl:applytemplates/><br/>
</xsl:template>
<xsl:template match=""/>
</xsl:stylesheet>
A
(
, , ,
XSLT):
<html>
<head>
<title>Song</title>
</head>
<body>
<div align="right"> </div>
<h1>Song</h1>
267
xsl:import
<p>
And
And
And
And
</p>
B
,
. ,
.
.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href=".xsl"/>
<xsl:template match="">
<xsl:number level="any" format="001"/>  
<xsl:applyimports/>
</xsl:template>
</xsl:stylesheet>
 
. HTML .
( Unicode #xa0),
DTD.
.
B
.
(,
   ,
.
<html>
<head>
<title>Song</title>
</head>
<body>
<div align="right"> </div>
<h1>Song</h1>
<p>
001
And suddenly the wind comes soft,<br>
002
And Spring is here again;<br>
003
And the hawthorn quickens with buds of green<br>
268
4. XSLT
004
And my heart with buds of pain.<br>
</p>
, .xsl,
, ,
.
, ,
.
, .xsl.
,
<xsl:number>, . 288.
<xsl:applyimports> , ,
,
.xsl.
.
<xsl:include>
<xsl:applyimports> . 174
xsl:include
<xsl:include> ,
.
, ,
, <xsl:include>.
XSLT, 2.6.1
<xsl:include> ,
<xsl:stylesheet>.
.
269
xsl:include
href
URI
URI ,
; .
URI, href,
URI. URI,
URI XML ,
<xsl:include>. , main.xsl
<xsl:include href="date.xsl"/>,
date.xsl , main.xsl. XSLT 1.1
, xml:base URI
, URI 2.
URI XML,
XSLT.
,
<xsl:include>. :
URI,
URI URI
. , ,
<xsl:include> <xsl:import>
URI document().
( ,
,
xsl:excluderesultprefixes ),
, .
, .
,
, ,
name namespace <xsl:element>.
270
4. XSLT
<xsl:import>
. <xsl:import>
,
, <xsl:import>,
. ,
, XSLT ,
.
, 3 (
).
<HTML>. ,
, ,
/
.
<xsl:include>
<xsl:import> .
.
, , .
.
,
.
, XSLT
,
.
<xsl:include> ,
#include C;
,
, .
,
. ,
,
, ,
, ,
.
xsl:include
271
<xsl:include>. ,
, <xsl:import>.
<xsl:include> , ;
.
, ,
, ,
. : .
Visual Basic , .
,
,
: ,
,
,
, <xsl:import>,
,
.
,
<xsl:include>.
XSLT
,
. ,
.
<xsl:include> ,
, ,
.
: <xsl:include>
.
.xsl,
.xsl.
.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href=".xsl"/>
<xsl:template match="/">
< xsl:useattributesets="">
272
4. XSLT
<xsl:attribute name=""></xsl:attribute>
</>
</xsl:template>
</xsl:stylesheet>
.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:attributeset name="">
<xsl:attribute name=""></xsl:attribute>
<xsl:attribute name="">100</xsl:attribute>
</xsl:attributeset>
</xsl:stylesheet>
,
, <xsl:include>.
:
< ="100" =""/>
: , <xsl:attribute>,
,
; ,
.
.
<xsl:import> . 256
xsl:key
<xsl:key> ,
, key()
.
XSLT, 12.2
273
xsl:key
<xsl:key> ,
<xsl:stylesheet>.
.
name
match
use
5,
6.
match, use
.
.
.
,
.
, match, use
key().
; .
name .
; ,
,
<xsl:key>.
, URI .
2.
match , .
, 6.
, .
,
, use.
274
4. XSLT
. ,
:
<>
< ="P427AGH" =" "/>
< ="T788PHT" =" "/>
< ="V932TXQ" =" "/>
</>
:
<xsl:key name="" match="" use="@"/>
use ,
. ,
@ . , .
,
. :
,
,
. :
,
.
.
,
.
,
. ,
,
. ,
,
.
,
, .
,
. . (N, V)
, N ,
match, use N
, V,
,
V. ,
.
, .
.
,
. key() ,
xsl:key
275
,
. ,
.
key(K, V), K , V
K
, , V.
SQL,
: , , .
key('K', 'V') SQL:
SELECT DISTINCT FROM WHERE
='K' AND
='V' AND
=;
: , ,
, ,
, .
, ,
. ,
key().
, , , ,
,
(
), ,
, .
<xsl:key> ,
, ,
.
,
.
:
<xsl:key name="" match="" use="@"/>
,
<>
. ,
.
, ABC456, ,
, :
<xsl:applytemplates select="key('', 'ABC456')"/>
276
4. XSLT
,
:
<xsl:key name="" match="/@" use="."/>
:
<xsl:applytemplates select="key('', 'ABC456')/.."/>
<xsl:applytemplates>.
<>,
ABC456 ( ,
), ,
, , .
,
XPath; ,
<xsl:valueof>.
key . , ,
, , ,
, ,
. , ,
URL, . ,
:
:
, ,
URL :
http://www.cheapfood.com/servlet/product?code=ABC456
( ASP,
), code
XSLT .xml ,
.xsl ABC456
,
, .
:
<xsl:param name=""/>
<xsl:key name="" match="" use="@"/>
<xsl:template match="/">
<html>
<body>
<xsl:variable name="" select="key('', $)"/>
<xsl:if test="not($)">
xsl:key
277
<p> , </p>
</xsl:if>
<xsl:applytemplates select="$"/>
</body>
</html>
</xsl:template>
,
,
. , ,
.
:
<xsl:key name="" match="" use="/"/>
use, /, ,
( )
, .
,
, , , ,
XPath:
<xsl:foreach select="key('', ' ')">
,
. , (Alex
Homer) (David Sussman) ?
,
.
, , Saxon xt,
intersection(),
XPath:
prefix:intersection(
key('', ' '),
key('', ' '))
. ,
, :
<xsl:variable name="1" select="key('', ' ')"/>
<xsl:variable name="2" select="key('', ' ')"/>
<xsl:variable name="" select="$1[ count(.|$2) =
count($2)]"/>
, count(X|Y)
, count(Y), X Y (,
| ); ,
278
4. XSLT
$1, ,
$2.
key().
, :
<xsl:variable name="" select="key('', ' ')">
<xsl:foreach select="key('', $//)">
select <xsl:foreach>
,
. $ ,
, $// ,
,
. ,
, .
:
,
,
. <>.
.xml:
<>
<>
<> </>
<> </>
<> </>
<> </>
<> </>
</>
<>
<> </>
<> </>
</>
<>
<> </>
<> </>
<> </>
<> </>
</>
<>
<> </>
<> </>
<> </>
<> </>
</>
</>
279
xsl:key
.xsl.
, <>,
, .
, :
saxon .xml .xsl =" "
, , ,
.
, . .
.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="" match="" use=""/>
<xsl:param name="" select="' '"/>
<xsl:template match="/">
<xsl:copyof select="key('', $)"/>
</xsl:template>
</xsl:transform>
, :
, :
<?xml version="1.0" encoding="utf8" ?>
<>
<> </>
<> </>
<> </>
<> </>
<> </>
</>
<>
<> </>
<> </>
</>
. :
<xsl:key name="isbn" match="" use="isbn"/>
<xsl:key name="" match="" use="/"/>
, , ISBN.
280
4. XSLT
, . ,
XSLT , ,
.
. ,
ISBN, :
<xsl:foreach select="//[isbn='0130826766']"/>
. :
<xsl:key name="" match="" use="/"/>
<xsl:key name="" match="CD" use=""/>
<xsl:key name="" match="CD" use=""/>
key() :
<xsl:applytemplates select="key('', ' ')"/>
, ,
<> <CD>, ; ,
,
, ,
.
use ,
. ,
, :
<xsl:key name="" match=" | CD" use=""/>
| CD,
<> <CD>.
6.
;
,
.
.
key() 7
281
xsl:message
xsl:message
<xsl:message> (
) .
XSLT, 13
<xsl:message> , .
terminate
yes | no
yes ,
.
no.
. ,
; XML.
, .
terminate , no.
, , ,
. XSLT ,
; ,
.
: .
terminate yes,
,
.
<xsl:message>
, .
282
4. XSLT
, , , <>
, .
terminate="no" ( )
.
terminate="yes"
.
<xsl:message> ,
, ,
. ,
: ,
,
.
, <xsl:message>, ,
.
, ( , xt)
,
.
<xsl:message>,
. , XSLT
.
<xsl:message>
,
. Saxon Xa
lan,
, xt ,
. ,
( <xsl:comment>). , ,
.
MSXML3 Microsoft
<xsl:message terminate="no">, .
terminate="yes" ,
HTML, .
, <> :
<xsl:if test="string(number())='NaN'">
<xsl:message terminate="yes">
<xsl:text> <> </xsl:text>
</xsl:message>
</xsl:if>
xsl:message
283
, XSLT ,
.
.
, ,
, .
.
<xsl:variable name=""
select="//[string(number(current()))='NaN']"/>
<xsl:template match="/">
<xsl:foreach select="$">
<xsl:message> <> <xsl:valueof select="."/>
</xsl:message>
</xsl:foreach>
...
<xsl:if test="$">
<xsl:message terminate="yes">
<xsl:text> </xsl:text>
</xsl:message>
</xsl:if>
</xsl:template>
XSLT , ,
,
. ,
, XSLT ,
, (
). ,
.
,
, ,
messages/de.xml. :
<>
< ="">Angefangen</>
< =""/>Bitte warten!</>
< =""/>Fertig</>
</>
,
, (
systemproperty(), 7,
).
:
<xsl:param name="" select="'en'"/>
284
4. XSLT
<xsl:template name="">
<xsl:param name=""/>
<xsl:variable name=""
select="concat('messages/', $language, '.xml')"/>
<xsl:variable name=""
select="document($)/"/>
<xsl:message>
<xsl:valueof select="$/[@=$]"/>
</xsl:message>
</xsl:template>
, .
xsl:namespacealias
<xsl:namespacealias> ,
, ,
. ,
XSLT.
XSLT, 7.1.1
<xsl:namespacealias
stylesheetprefix=
resultprefix= />
<xsl:namespacealias> ,
<xsl:stylesheet>.
.
stylesheetprefix
|
#default
resultprefix
|
#default
; <xsl:namespacealias> .
xsl:namespace5alias
285
<xsl:namespacealias>
.
,
,
, URI ,
. ,
, .
.
,
URI . ( XSLT
,
, ,
, ,
.
xsl:excluderesultprefixes.
. 3.)
, ,
XSLT. <xsl:template>,
XSLT. <xsl:template>
, ,
XSLT,
XSLT.
<xsl:namespacealias>,
XSLT.
,
<out:template>, <xsl:namespacealias>,
, out
xsl.
<xsl:namespacealias> , URI
URI
URI URI. URI
, ,
URI ,
. URI
URI ,
#default.
, <xsl:namespacealias>
, , URI.
URI
. URI
286
4. XSLT
,
. ,
<xsl:element>, , <xsl:attribute>,
, <xsl:copy>.
( stylesheetprefix, resultprefix),
, ,
, ,
URI .
<xsl:namespacealias>,
stylesheetprefix, ,
. ,
,
.
URI ,
. ,
. ,
,
,
URI ,
, .
,
. , ,
, :
.
XSLT
,
XSLT?
,
, XSLT, ,
.
XSLT.
XSLT .
, XPath,
(XSLT ).
,
.
,
XSLT.
xsl:namespace5alias
287
: ,
. ,
HTML, <CENTER>.
<CENTER> ,
, <DIV ALIGN="CENTER">.
XSLT?
,
XSLT (. , Schematron
http://www.ascc.net/xml/resource/schematron/schematron.html).
, XML,
XML XML, XSLT.
, ,
XSLT XML,
,
XSLT.
, <xsl:namespacealias>
. XSLT
URI ,
. ,
; ,
, , ,
,
.
<xsl:namespacealias>
XSLT,
,
.
, <xsl:include>
<xsl:import> , .
alias.xsl.
XML
. (
).
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslt="output.xsl">
<xsl:param name="variablename">v</xsl:param>
<xsl:param name="defaultvalue"/>
288
4. XSLT
<xsl:output indent="yes"/>
<xsl:namespacealias stylesheetprefix="xslt" resultprefix="xsl"/>
<xsl:template match="/">
<xslt:stylesheet version="1.0">
<xslt:variable name="{$variablename}">
<xsl:valueof select="$defaultvalue"/>
</xslt:variable>
</xslt:stylesheet>
</xsl:template>
</xsl:stylesheet>
variablename defaultvalue
, .
Saxon, .
<?xml version="1.0" encoding="utf8"?>
<xslt:stylesheet
xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslt:variable name="v"/>
</xslt:stylesheet>
,
xsl? , , Saxon:
, XSLT 1.0 XSLT 1.1,
, ,
. Saxon ,
URI
, .
,
xsl, ,
<xslt:variable> <xslt:stylesheet>.
xslt,
,
.
.
3.
xsl:number
<xsl:number> .
,
289
xsl:number
. ,
.
, <xsl:number>
, formatnumber()
<xsl:decimalformat>.
XSLT, 7.7
<xsl:number
level="single" | "multiple" | "any"
count=
from=
value=
format={}
lang={)
lettervalue={ "alphabetic" | "traditional" }
groupingseparator={}
groupingsize={} />
<xsl:number> , .
level
single |
multiple |
any
count
, ,
from
:
,
value
(
)
format
,
,
290
4. XSLT
lang
,
,
,
XML xml:lang
lettervalue
, al ,
phabetic | traditional
groupingseparator ,
,
(,
)
groupingsize
, , ,
, . 5.
, . 6.
; .
<xsl:number> :
,
value ,
value
( )
number().
round(). level,
count from .
, , ,
(, , 0.5),
291
xsl:number
<xsl:number> .
XSLT ,
,
, ,
string(). <xsl:number>
, ,
formatnumber(), 7.
value , <xsl:number>
.
level, count from. ,
:
level
single
count
, , ,
, ,
. ,
, URI , .
from
, ,
*[false()].
.
level single any,
, multiple,
(, 3.6.1).
, .
:
(level)
single
, .
count, .
,
count, .
, , from,
.
,
,
count,
. ,
,
count, 7.
292
4. XSLT
(level)
,
.
any
,
: ,
.
, , ,
count, , ,
from, .
preceding, ancestor self.
.
count,
. .
multiple
, , 2.17.1.
, , ,
from, . ,
from, .
,
.
, count,
,
, count,
.
.
.
,
, .
.
, ,
.
, , ,
format. ,
1.
.
,
.
, 1((a)),
xsl:number
293
1, ((,
a )).
Unicode
.
.
, ,
, , .
, 42, [1],
[42].
,
, : ,
3, 1, 6, 1.1(a),
3.1(f) ( f ).
:
n , ,
n ,
.
, ,
. , 3,1,2,5,
A.1, C.1.2.5.
,
1.
, ,
.
, ,
, ,
.
, , ..
,
.
, ,
. ,
[1], [].
,
count.
, ,
,
.
294
4. XSLT
XSLT .
, ,
.
:
1, 2, 3, 4
01
Unicode
Unicode, ,
.
,
.
a, b, c, d, x, y, z, aa, ab, ac
A, B, C, D, X, Y, Z, AA, AB, AC
, ,
,
1000 ( , ,
,
XML).
groupingseparator groupingsize
. , grouping
separator=" " ( ), groupingsize="2" 12345
1 23 45.
.
XSLT
. ,
,
, , XSLT
. ,
1. ,
, eins,
zwei, drei, vier, ,
eins;
, , , , .
xsl:number
295
,
, ,
.
lang : ,
, a
(lang="en") (lang="se").
, xml:lang, XML.
lettervalue ,
,
.
alphabetic traditional.
,
,
.
, ,
, ,
. , ,
.
, : . <xsl:message> . 281.
<xsl:number>
.
(,
),
:
<xsl:variable name=""><xsl:number/></xsl:variable>
. ,
(*, , , , ),
<xsl:number>,
, .
, :
<xsl:template match="footnote"/>
<xsl:variable name="footnotenumber">
<xsl:number level="any" from="section"/>
</xsl:variable>
<xsl:valueof select="translate($footnotenumber, '12345', '*')"/>
,
, Unicode. translate() ,
296
4. XSLT
,
: 7.
, ,
,
, .
, , XSL Format
ting, XSL Transformations.
<xsl:number> ,
.
,
<xsl:number>
. ,
.
level="single"
( )
.
<xsl:number> :
<xsl:number/>
<item>
,
8. ,
count,
count , <item>.
position(), .
, ,
<xsl:number>,
,
. position() ,
. ,
, position() <xsl:number/>
,
.
count(), : count(precedingsibling::item)+1. ,
,
.
count <xsl:number> .
xsl:number
297
, ,
. , ,
<> <
>:
<>
<></>
<></>
<> </>
<></>
<> </>
<></>
</>
,
:
<xsl:template match=" | ">
<xsl:number count=" | "/>
<xsl:text> </xsl:text>
<xsl:valueof select="."/><br/>
</xsl:template>
<> :
1
2
3
4
5
6
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
, count="*".
count , :
1
2
1
3
2
4
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
.
count ,
, . ,
<> <xsl:number>
, :
<xsl:template match="">
<xsl:number count=""/>
. . .
</xsl:template>
298
4. XSLT
:
,
<>.
from level="single".
, .
,
, ,
<xsl:number> , XPath
. , ,
, :
<xsl:template match="">
<xsl:param name="" select="1"/>
<xsl:variable name=""><xsl:number/></xsl:variable>
<xsl:valueof select="$ + $ 1"/>
. . .
</xsl:template>
level="any"
, ,
, ,
. , ,
, , .
count .
,
:
<xsl:template match="">
<table><tr><td width="90%" valign="top">
<i><xsl:valueof select="."/></i></td>
<td><xsl:number level="any"/></td>
</tr></table>
</xsl:template>
, count ,
, ,
, , .
, <xsl:number>
.
, ,
<xsl:number>. , ,
. ,
,
. ,
, , position().
, ,
.
xsl:number
299
XSLT 1.1 ,
.
<>,
.
.
XSLT 1.0
nodeset().
, ,
:
<>
<>XML</>
<> </>
</>
:
<xsl:template name="">
<xsl:variable name="">
<xsl:foreach select="//">
<xsl:sort select=""/>
<xsl:copyof select="."/>
</xsl:foreach>
</xsl:variable>
<table>
<xsl:foreach select="$/">
<tr>
<td><xsl:number format="[1]"/></td>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select=""/></td>
</tr>
</xsl:foreach>
</table>
</xsl:template>
, ,
, position().
from ,
:
<xsl:template match="">
<xsl:number level="any" from=""/>
<xsl:text> </xsl:text>
<xsl:valueof select="."/>
</xsl:template>
, 1 .
300
4. XSLT
:
,
.
, <>,
<> <>:
, .
.xml,
1.
.xsl.
<xsl:number>,
, mod,
.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body>
<p><xsl:applytemplates select="//"/></p>
</body></html>
</xsl:template>
<xsl:template match="">
<p><table><xsl:applytemplates/></table></p>
</xsl:template>
<xsl:template match="">
<tr>
<td width="350"><xsl:valueof select="."/></td>
<td width="50">
<xsl:variable name="">
<xsl:number level="any" from=""/>
</xsl:variable>
<xsl:if test="$ mod 3 = 0">
<xsl:valueof select="$"/>
</xsl:if>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
301
xsl:number
. 4.6.
level="multiple"
,
, 1.12.3 A2(iii).
,
<xsl:number> level=
"single" count, :
<xsl:number count=""/>.<xsl:number count=""/>
(<xsl:number count=""/>)
, ,
, . ,
, .
level="multiple" ,
( , <>
<>)
.
count ,
. :
<xsl:template match="">
<xsl:number
format="1.1.1. "
302
4. XSLT
level="multiple"
count=" | | "/>
<xsl:applytemplates/>
</xsl:template>
,
,
( ), <>, <> <>.
, ,
1.13.5, 1
, 13 , 5 .
: , ,
, ,
, , ,
,
.
, ,
. ,
1.2.3, A.2.3.
, ,
. , , :
<xsl:template match="">
<xsl:variable name="">
<xsl:choose>
<xsl:when test="ancestor::">1.1.1. </xsl:when>
<xsl:otherwise>A.1.1 </xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:number
format="{$}"
level="multiple"
count=" | | | "/>
<xsl:applytemplates/>
</xsl:template>
.
count() 7
position() 7
formatnumber() 7
<xsl:decimalformat> . 226
xsl:otherwise
<xsl:otherwise> <xsl:choose>
, ,
<xsl:when>.
xsl:output
303
XSLT, 9.2
<xsl:otherwise>
</xsl:otherwise>
<xsl:otherwise>
<xsl:choose>. ,
<xsl:choose>, .
<xsl:otherwise> , (
) <xsl:when>
<xsl:choose> .
. <xsl:choose> . 213.
.
<xsl:choose> . 213
<xsl:when> . 381
xsl:output
<xsl:output> ,
.
XSLT :
,
. <xsl:output>
, .
304
4. XSLT
XSLT;
, DOM
API. , ,
. ,
, ,
, , API .
TrAX API . F.
XSLT, 16
<xsl:output
method= { "xml" | "html" | "text" | }
version= { }
encoding= { }
omitxmldeclaration= { "yes" | "no" }
standalone= { "yes" | "no" }
doctypepublic= { }
doctypesystem= { }
cdatasectionelements= { }
indent= { "yes" | "no" }
mediatype= { } />
<xsl:output> ,
<xsl:stylesheet>.
.
; .
xsl:output
305
<xsl:output>.
, , ,
<xsl:output>
:
cdatasectionelements
<xsl:output> , ,
, CDATA.
<xsl:output>,
, ,
. <xsl:output>
,
.
( ), XSLT
, ,
.
method , , ,
.
: xml, html text.
, ,
,
, .
, .
<xsl:output>,
<xsl:output> , ,
.
method , XML,
HTML. HTML,
:
, , ,
<html> (
) URI
,
<html> , (
) , .
XML
xml,
XML,
XML.
, , XML
306
4. XSLT
&doc;.
,
:
A <b>bold</b> and <emph>emphatic</emph> statement
. ,
, , ,
standalone , ,
XML, ,
.
,
, :
<?xml version="1.0" encoding="utf8" standalone="yes"?>
<p>A <b>bold</b> and <emph>emphatic</emph> statement</p>
, :
. 4.7.
, XSLT ,
: , XML
,
.
, :
DTD, ,
, ,
xsl:output
307
XML
:
extParsedEnt TextDecl ? content
:
document XMLDecl ? Misc * doctypedecl ? Misc * element Misc *
Misc ,
.
, :
TextDecl ( ) , XMLDECL (
XML), .
doctypedecl ( ),
.
<!DOCTYPE ... >, DTD , ,
DTD.
element (),
content ().
,
.
TextDecl ( )
XML: , <?xml version="1.0" encoding="utf8"?>
XML, .
:
XML version ,
XML encoding ,
XML standalone,
,
, , , CDATA,
,
.
:
<>!</>
<>!</><> !</>
!
<?xml version="1.0" encoding="utf8"?>!
308
4. XSLT
XML,
:
standalone, . :
<?xml version="1.0" encoding="utf8" standalone="no"?>
<!DOCTYPE SYSTEM "hello.dtd">
<>!</>
XML,
.
<?xml version="1.0" encoding="utf8" standalone="no"?>
<!DOCTYPE SYSTEM "hello.dtd">
<>!</>
<> !</>
XML,
,
, <!DOCTYPE>. ,
XSLT 1.0, , ,
, .
XSLT
, , ,
. :
XML (XML Namespaces Recommendation). XML
,
, .
:
,
XML.
.
,
, .
,
XSLT 1.0 XSLT 1.1. XSLT 1.0
.
, ,
,
, . ,
, , <xsl:element>
<xsl:attribute>, URI
, .
XSLT 1.1 , (na
mespace fixup), ,
,
, .
309
xsl:output
. , XSLT 1.1
( )
, .
, XML,
, XML (,
XML, , XML,
DTD).
, DTD, ,
XSLT ,
DTD; .
xml <xsl:output>
:
version
XML, .
XML 1.0,
.
, ,
, 1.0.
encoding
. XSLT
UTF8 UTF16 (
,
XML).
XML Text ,
, .
.
XML, iso88591,
, , , ,
, XML (,
₤). ,
, (,
,
).
indent
yes, , XML
, .
XSLT ,
.
.
, ,
.
, ,
. ,
, .
310
4. XSLT
,
. ,
,
.
cdatasection ,
elements
.
URI ,
,
<xsl:output>, cdatasectionelements.
, , ,
.
,
,
CDATA. , James
<![CDATA[James]]>, AT&T
<![CDATA[AT&T]]>.
, ,
AT&T. XSLT
, ,
, CDATA,
. (
: , ,
.)
CDATA :
]]>,
,
,
.
omitxml
declaration
yes, XSLT
XML (, ,
; , XML
,
).
no, .
version, encoding (
, XML,
). standalone
, <xsl:output>.
standalone
yes, XML
standalone="yes".
no, XML
standalone="no".
, XML
standalone. ,
311
xsl:output
. ,
XML.
doctypesystem , ,
( <!DOCTYPE>) XML
.
, .
. ,
XML.
doctypepublic , doctypesys
tem. ,
.
,
.
mediatype
(
MIME). text/xml.
, :
,
,
. ,
HTTP.
, <xsl:output> ,
XSLT XML.
DOM,
, DOM (,
save xml DOM Microsoft),
<xsl:output> .
HTML
method html ,
HTML, HTML.
HTML 4.0.
XSLT XHTML,
,
XHTML. XHTML XML,
XHTML, xml.
XML XHTML,
HTML: , <hr />
. XSLT.
HTML , XML,
. :
312
4. XSLT
.
.
, . HTML 4.0
:
<area>
<base>
<basefont>
<br>
<col>
<frame>
<hr>
<img>
<input>
<isindex>
<link>
<meta>
<param>
<script> <style> (,
) .
< <,
<.
HTML, URI (, href
<a> src <img>), ,
URI ,
HTML. , , ASCII, URI
UTF8 %HH, HH .
,
é, HTML.
XSLT,
.
>, ?>.
HTML, HTML 4.0
,
, . ,
, .
,
, .
<TEXTAREA READONLY> <OPTION SELECTED>. ,
SGML, XML, ,
, , . XML
<TABLE BORDER="BORDER"> <OPTION SE
LECTED="SELECTED">. HTML
, ,
HTML.
HTML. , <TD WIDTH="&{width};">
HTML, XML.
,
<TD WIDTH="&{{width}};">;
.
313
xsl:output
HTML
URL. , , :
<a href="http://www.acme.com/search.asp?product=widgets&country=spain>
Spanish Widgets
</a>
, XSLT:
&. : &,
, HTML,
, &.
,
.
HTML, <xsl:output>
:
version
HTML, .
HTML ,
,
4.0.
encoding
.
charset <>,
<HEAD>, .
XML, iso88591,
, , , ,
.
, :
, (
, )  ,
&#a0; . ,
, ,
(, ,
).
indent
yes, , HTML
,
. XSLT ,
.
,
XML, HTML
.
, HTML .
cdatasection HTML.
elements
314
4. XSLT
omitxml
declaration
HTML.
standalone
HTML.
doctypesystem ,
. HTML html.
system
.
doctypepublic ,
. HTML html.
public
.
mediatype
(
MIME). text/xml.
, :
,
,
. ,
HTTP.
method="text",
. ,
.
, ,
encoding; &,
.
(, LF CRLF) ;
, .
, ,
. .
encoding
. ,
, .
XML, iso88591,
.
(
MIME). text/plain.
315
xsl:output
mediatype
, :
,
, .
, HTTP
.
,
<xsl:output> .
XML , <HTML>,
HTML.
<xsl:output> ,
. XSLT
, , Document DOM
SAX, <xsl:output> .
encoding ,
. ,
, XSLT
. , XSLT
Java Java
, ,
Java, .
iso88591 ,
UTF8
Unicode, iso88591.1
, , ,
, UTF8,
, UTF8.
encoding , XSLT
, ,
. , ,
. API
, ,
,
. transformNode()
Microsoft (. A),
BSTR. BSTR,
1
.
,
XSLT, UTF8. . . .
316
4. XSLT
UTF16, .
TrAX (. F); StreamResult,
Writer, ,
Writer Unicode, XSLT
.
XML, iso
88591. ,
<script>
CDATA. DTD .dtd: ,
,
DTD , ,
XML.
<xsl:output
method="xml"
indent="yes"
encoding="iso88591"
cdatasectionelements="script"
doctypesystem=".dtd" />
,
, US ASCII:
<xsl:output
method="text"
encoding="usascii" />
xsl:param
<xsl:param> ,
, <xsl:template>,
.
, ,
.
XSLT, 11
317
xsl:param
<xsl:param> (
<xsl:stylesheet>)
<xsl:template>. <xsl:param>
.
name
select
,
5.
(). select,
.
<xsl:param>
; <xsl:param>,
<xsl:template>,
.
<xsl:param>
. ,
.
<xsl:withparam>, <xsl:apply
templates>, <xsl:calltemplate> ( XSLT 1.1) <xsl:applyimports>.
(,
API).
F TrAX API.
select . se
lect, <xsl:param> . select
, .
318
4. XSLT
,
, , ,
. ,
. XSLT 1.0
; XSLT 1.1 ,
.
<xsl:variable>, . 370.
. (
), :
, my:value. ,
,
.
, URI ,
, , my:value your:value,
, my your URI
. ,
: URI ,
URI .
, ,
(, $num),
, <xsl:param>
<xsl:variable>.
, .
, . , XSLT
.
Java Server Page Java, ASP.
,
API, . API
,
HTTP,
<xsl:param>.
API ,
: , , ,
. ,
, document().
Document DOM.
<xsl:calltemplate>,
<xsl:applytemplates>, , XSLT 1.1
xsl:param
319
<xsl:applyimports>.
<xsl:withparam>. ,
XSLT, :
<xsl:calltemplate> . 204.
: <xsl:param>
XML.
.xsl.
, (
).
; ,
.
,
,
.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:foreach select="//*">
<xsl:valueof select="concat(name(), ' ')"/>
<xsl:calltemplate name="depth"/>;
</xsl:foreach>
</xsl:template>
<xsl:template name="depth">
<xsl:param name="node" select="."/>
<xsl:valueof select="count($node/ancestor::node())"/>
</xsl:template>
</xsl:transform>
.xml,
1, :
1;
2;
320
4. XSLT
2;
2;
2;
3;
3;
3;
3;
2;
3;
3;
3;
3;
2;
3;
3;
3;
3;
.
<xsl:applytemplates> . 178
<xsl:calltemplate> . 204
<xsl:variable> . 370
<xsl:withparam> . 383
xsl:preservespace
<xsl:preservespace> <xsl:stripspace>
.
XSLT, 3.4
<xsl:preservespace> ,
<xsl:stylesheet>.
.
321
xsl:preserve5space
elements
, ,
,
,
(NameTest) 5.
, *,
prefix:*,
.
; .
, <xsl:stripspace>, ,
,
. <xsl:strip
space> <xsl:preservespace> ,
,
, .
, ,
, ,
,
<xsl:stripspace>. .
, ,
3.
<xsl:preservespace>
,
document().
, ,
document(),
, .
,
. ,
, ,
XSLT,
XML,
( MSXML3 Microsoft),
<xsl:preservespace>,
.
322
4. XSLT
,
:
, ,
(#x20, #x9, #xD #xA). <xsl:preservespace>
, ,
;
.
, , .
,
XML.
. , . ,
,
.
, ,
,
XML.
xml:space,
xml:space="preserve",
<xsl:preservespace> <xsl:stripspace> .
elements <xsl:preservespace>
, .
(NameTest) XPath; . 5.
.
:
title
svg:width
, 0
URI
svg:*
:*
0.25
, URI
0.5
, . ,
:
<xsl:stripspace elements="*"/>
<xsl:preservespace elements="para clause"/>
,
<para> <clause>, .
<xsl:stripspace>, <xsl:preservespace>,
(0 0.5).
xsl:preserve5space
323
<xsl:stripspace> <xsl:preservespace>,
, <xsl:strip
space> <xsl:preservespace> .
,
<xsl:stripspace>,
.
,
<xsl:stripspace>,
, <xsl:preservespace>.
<xsl:stripspace>,
<xsl:preservespace>,
.
<xsl:stripspace> <xsl:preservespace>,
, XSLT
( <xsl:import> . 256).
,
, .
, ,
, .
<xsl:preservespace>,
; <xsl:stripspace>
.
,
.
. , ,
: .
, XML,
xml:space="preserve" xml:space="default", ,
. , <xsl:preservespace>
<xsl:stripspace>, , ,
. , <xsl:stripspace>
, ,
DTD
xml:space preserve .
.
,
,
, :
<xsl:stripspace elements="*"/>
324
4. XSLT
.
:
<xsl:applytemplates> select
, .
,
, , .
position(),
.
, 2, 4, 6, 8
, , ,
, DTD ,
#PCDATA.
, #PCDATA; ,
. ,
,
, ,
, ,
.
(,
DTD , #PCDATA)
. , :
<quote>He went to <edu>Balliol College</edu> <city>Oxford</city> to read
<subject>Greats</subject></quote>
<edu> <city>
, , ,
, ,
College Oxford .
:
<xsl:stripspace elements="*"/>
:
<xsl:stripspace elements=" "/>
,
<>:
<xsl:stripspace elements="*"/>
<xsl:preservespace elements=""/>
325
xsl:processing5instruction
,
URI http://mednet.org/text:
<xsl:stripspace elements="*"/>
<xsl:preservespace elements="mednet:*" xmlns:mednet="http://mednet.org/text" />
.
<xsl:stripspace> . 336
xsl:processinginstruction
<xsl:processinginstruction>
.
XSLT, 7.3
<xsl:processinginstruction> ,
.
name
, ()
( XML
, PITarget) name.
. ,
, XML XSLT,
,
(NCName), XML Namespaces Recom
mendation. , XML,
326
4. XSLT
( , NCName)
xml (
).
, <xsl:processinginstruction>
XML
. XML ,
; xml
. XML
XSLT , ,
<xsl:output>.
. ,
, . ,
,
?>,
. ?> ? > ( );
, ,
, ,
.
(
₤), ,
.
, ,
XML, XSLT
.
, .
XML, , , <xsl:processinginstruction>
. HTML ,
HTML 4.0 ,
. HTML
>, ?>,
HTML; . <xsl:output> . 303.
, ,
.
.
<xsl:copy>
<xsl:copyof>.
<?xmlstylesheet?>
.
xsl:processing5instruction
327
<xsl:processinginstruction name="xmlstylesheet">
<xsl:text>href="housestyle.css" type="text/css"</xsl:text>
</xsl:processinginstruction>
:
<?xmlstylesheet href="housestyle.css" type="text/css"?>
XSLT, XML,
CSS,
, .
XML ,
( , ). ,
, , ,
, .
.
CSS, XSLT; , CSS ,
,
XSLT .
<?xmlstylesheet?>
,
.
, . href="housestyle.css"
XML,
XML, .
, XML.
XML, ,
<xsl:attribute>; .
<?xmlstylesheet?>
W3C, XML
(Associating Style Sheets with XML Documents)
http://www.w3.org/TR/xmlstylesheet.
, ₤,
, > &. ,
,
XML,
XSLT. ₤
, , , :
<xsl:processinginstruction name="xmlstylesheet">
<xsl:text>href="housestyle.css" type="text/css"</xsl:text>
<xsl:text>title=" &#x20A4;"</xsl:text>
</xsl:processinginstruction>
328
4. XSLT
xsl:script
<xsl:script> ,
, XPath
. <xsl:script> ,
XSLT 1.1. XSLT 1.0
, : , MSXML3
Microsoft <msxml:script>,
.
XSLT 1.1
Java JavaScript, XSLT
,
, .
XSLT 1.1, 14.4
<xsl:script
implementsprefix =
language = "ecmascript" | "javascript" | "java" |
src = URI
archive = URI >
</xsl:script>
<xsl:script> ,
<xsl:stylesheet> <xsl:transform>.
<xsl:script>;
,
<xsl:script> language
implementsprefix (, , ,
URI ),
. <xsl:script> .
implementsprefix
,
. (,
,
URI .)
329
xsl:script
language
ecmascript |
javascript |
java |
,
. (
)
,
.
src
URI
(
),
. ,
<xsl:script>.
archive
URI, ,
,
.
src, .
src ,
.
, .
XML < &,
CDATA <![CDATA[ ]]>, .
<xsl:script> ,
, .
XPath,
, my:function(). my
URI , ,
XPath; ,
<xsl:script>, ,
URI .
URI
, , .
,
,
XSLT ,
.
.
,
. ,
; ,
330
4. XSLT
,
.
<xsl:script>
URI . Ja
va, , URI
, , <xsl:script>
, ,
<xsl:script>. JavaScript, ,
,
<xsl:script> .
, .
JavaScript .
<xsl:script>
, src, src=".js".
Java
XSLT, Java
, URI,
(, src="java:com.acme.toolslib.Widget",
, archive,
CLASSPATH,
JAR, ).
<xsl:script>
. Java
Script Java ( , ecma
script javascript, ,
).
, B Perl, .
8.
.
Ja
va JavaScript 8 .
xsl:sort
<xsl:sort>
, ,
<xsl:applytemplates> <xsl:foreach>.
331
xsl:sort
XSLT, 10
<xsl:sort
select=
order={"ascending" | "descending"}
caseorder={"upperfirst" | "lowerfirst"}
lang={}
datatype={"text" | "number" | }/>
<xsl:sort> <xsl:apply
templates> <xsl:foreach>.
.
<xsl:foreach> <xsl:sort>
<xsl:foreach>.
<xsl:applytemplates> <xsl:sort> ,
<xsl:withparam>.
select
.
( string(.)).
order
, :
ascending |
descending
,
:
.
ascending.
caseorder
, :
upperfirst |
lowerfirst
,
.
.
lang
,
,
.
.
datatype
, :
text |
number |
,
,
.
text.
332
4. XSLT
; .
<xsl:sort> <xsl:applytemplates>
<xsl:foreach> ,
. ;
, ,
, .
,
. ,
, .
, select.
, ,
.
,
, :
<xsl:sort select="position()"
datatype="number"
order="descending" />
, data
type number, .
<xsl:sort>. XSLT
, ,
.
, .
, select ,
, ,
, .
,
. :
<xsl:param name="" >
. . .
<xsl:foreach select="">
<xsl:sort select="$"/>
, $ ,
, $
, . :
$
<>,
xsl:sort
333
. ,
, , :
<xsl:sort select="*[localname()=$]">
,
.
, , :
<xsl:sort select="[$=''] |
[$=''] |
@isbn[$='isbn']">
(
|),
, , , ,
.
datatype text number.
text, 10 , 5, number
.
. ,
. ,
, .
(
XSLT 1.0 , ,
.)
,
. ,
lang. ,
a ( ,
ae),
, , z. XSLT
Unicode , #10
Unicode (Unicode Technical Report #10),
Unicode (Unicode Collation Algorithm). . http://
www.unicode.org/unicode/reports/tr10/index.htm.
.
(
), XSLT , caseorder.
, caseorder
, , .
, ,
, drall
( )
Drall (, ),
334
4. XSLT
. case
order="lowerfirst" drall Drall,
caseorder="upperfirst" Drall,
drall.
order ,
.
. , , ,
, , caseorder
: caseorder="upperfirst" order="descending",
drall Drall. ( ,
XSLT 1.0, ,
.)
datatype=""
1.0, .
,
. ,
, , XML
Schema Recommendation; XML Schema
, XSLT 2.0.
,
<xsl:applytemplates> <xsl:foreach>, positi
on() . position()
.
XSLT
, , ,
. , ,
; ,
. ,
, .
,
, .
1: <> ,
isbn:
<xsl:applytemplates select="">
<xsl:sort select="@isbn"/>
</xsl:applytemplates>
335
xsl:sort
2: <>
, :
<ul>
<xsl:foreach select="//[not(.=preceding::)]">
<xsl:sort select="."/>
<li><xsl:valueof select="."/></li>
</xsl:foreach>
</ul>
select="." <xsl:sort>,
, ;
.
:
,
.
.xml:
<>
< =" ">
< ="" ="20.00"/>
< ="" ="50.00"/>
</>
< =" ">
< ="" ="205.16"/>
< ="" ="10.50"/>
</>
< =" ">
< ="" ="320.20"/>
< ="" ="39.50"/>
</>
</>
.xsl ,
,
.
3.
<xsl:sort> (
<>)
<>.
sum() formatnumber().
< xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:foreach select="/">
<xsl:sort select="sum(/@)" datatype="number" order="descending"/>
336
4. XSLT
<product name="{@}"
sales="{formatnumber(sum(/@), '$####0.00')}"/>
</xsl:foreach>
</>
, :
<>
< =" " ="$359.70"/>
< =" " ="$215.66"/>
< =" " ="$70.00"/>
</>
.
<xsl:applytemplates> . 178
<xsl:foreach> . 248
xsl:stripspace
<xsl:stripspace>, <xsl:preservespace>,
. <xsl:stripspace> ,
.
XSLT, 3.4
<xsl:stripspace> ,
<xsl:stylesheet>.
.
elements
,
, ,
(NameTest) 5.
xsl:stylesheet
337
; .
,
. <xsl:preservespace> . 320. , <xsl:stripspace>
<xsl:preservespace>, ,
.
.
<xsl:preservespace> . 320
<xsl:text> . 360
xsl:stylesheet
<xsl:stylesheet> .
, <xsl:transform>.
XSLT, 2.2
<xsl:stylesheet
id=identifier
version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
extensionelementprefixes=
excluderesultprefixes= >
*
</xsl:stylesheet>
<xsl:stylesheet>
, ,
, 3.
, ,
.
, <xsl:stylesheet>
, XML , ,
. 3,
XML.
338
4. XSLT
<xsl:stylesheet>, , , ,
:
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
,
XSLT. URI , . xsl
XSLT,
, ,
XSLT. <XSLT:stylesheet>
<xsl:stylesheet>.
, :
xmlns="http://www.w3.org/1999/XSL/Transform"
<stylesheet>, XSLT
, , <template>,
<xsl:template>. , ,
.
,
.
,
:
xmlns:xsl=http://www.w3.org/TR/WDxsl
XSLT, ,
WDxsl, XSL, Microsoft 1998 Internet
Explorer 5. XSLT .
Microsoft XSL . A.
XML
Id
,
<xsl:stylesheet>,
XML.
version
XSLT,
. 1.1
,
XSLT 1.1, 1.0, ,
XSLT 1.0 XSLT 1.1.
339
xsl:stylesheet
extension
,
elementprefixes ,
.
excluderesult
prefixes
,
,
,
,
.
<xsl:stylesheet> XSLT,
. :
<xsl:attributeset>
<xsl:decimalformat>
<xsl:import>
<xsl:include>
*
<xsl:key>
<xsl:namespacealias>
<xsl:output>
<xsl:param>
<xsl:preservespace>
<xsl:script> *
<xsl:stripspace>
<xsl:template>
<xsl:variable>
<xsl:import>,
.
<xsl:stylesheet>
, URI ,
URI XSLT. XSLT URI
, ,
, ,
.
, .
id
<xsl:stylesheet>,
XML.
,
, id
<?xmlstylesheet?> . 3.
340
4. XSLT
version
version XSLT,
.
XSLT, 1.0 1.1, ,
.
XSLT, 1.0 ,
,
1.0.
<xsl:apply_template>, (
<xsl:applytemplates>). , XSLT 1.1
XSLT, version
1.0 1.1.
version (
1.0), ,
,
XSLT, . , ver
sion 2.1 <xsl:apply_template>,
, ,
2.1 , <xsl:applytemplates>.
XSLT
. <xsl:app
ly_template> , : (a)
, (b) <xsl:fallback>.
<xsl:fallback>, ,
.
<xsl:fallback> . 243.
. , ver
sion 1.0 ( XSLT 1.1 1.1)
XSLT
,
.
XSLT <xsl:sort>,
, ,
.
version , ,
,
xsl:version. ,
, <xsl:include>
<xsl:import>.
xsl:stylesheet
341
extensionelementprefixes
,
.
, .
, ,
. ,
XSLT, ,
.
, extensionelementprefixes
<xsl:stylesheet>,
, .
,
;
, <xsl:stylesheet>.
( ,
xmlns)
#default.
, ,
xsl:extension
elementprefixes .
, .
extensionelementprefixes
, ,
<xsl:include> <xsl:import>.
, XSLT ,
. XSLT
. , http://
www.jclark.com/xt/extensions ,
xt, Xalan , , xt
, Xalan . ,
, ; ,
<xsl:fallback>. ,
<xsl:fallback>, .
,
.
.
, ,
, .
, extensionelementprefixes
, ,
. ,
<msxml:script> , , Micro
342
4. XSLT
soft MSXML3, , ( ,
).
excluderesultprefixes
,
.
XSLT ,
( 2)
XML, ,
.
,
,
, ,
, .
,
, .
,
, DTD. ,
excluderesultprefixes .
, XSLT ,
, XSLT
, .
, ,
, .
,
,
, .
, ,
,
.
, :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<xsl:template match="/">
<acme: xmlns:acme="http://acme.com/xslt">
<acme:>
...
</acme:>
</acme:>
</xsl:template>
</xsl:stylesheet>
,
, 2 3.
xsl:stylesheet
343
,
, , , <acme:>
,
. (
xml, .)
. 4.8. .
,
(
XSLT), (
xml):
344
4. XSLT
. 4.9. :
, <acme:> <acme:>,
acme. ,
:
, XML.
XSLT
, ,
:
<acme: xmlns:acme="http://acme.com/xslt">
<acme:>
...
</acme:>
</acme:>
excluderesultprefixes
, , ,
. , , :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:var="http://another.org/xslt"/>
<xsl:variable name="var:x" select="17"/>
<xsl:template match="/">
<acme: xmlns:acme="http://acme.com/xslt">
xsl:stylesheet
345
<acme:>
...
</acme:>
</acme:>
</xsl:template>
</xsl:stylesheet>
, ,
<acme:> <acme:>
, ,
, :
<acme:document xmlns:acme="http://acme.com/xslt"
xmlns:var="http://another.org/xslt">
<acme:>
...
</acme:>
</acme:>
XSLT
? , XML,
XSLT,
. ,
, .
XSLT ,
.
, ,
, excluderesultprefixes
<xsl:stylesheet>. ,
.
#default.
, ,
URI : ,
URI . , URI
,
.
excluderesultprefixes <xsl:stylesheet>
.
, ,
xsl:excluderesultprefixes
.
xsl:excluderesultprefixes excluderesultprefixes
, ,
.
,
<xsl:copy> <xsl:copyof>; .
346
4. XSLT
<xsl:stylesheet>, exclude
resultprefixes
, ,
<xsl:include> <xsl:import>.
, ,
, ? XSLT
,
,
. (, XSLT 1.0
.
XSLT 1.1 :
, ,
URI ,
.)
<xsl:stylesheet>
( ).
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
>
.
id
XSLT
, ,
:
<?xml version="1.0"?>
<?xmlstylesheet href="#style" type="text/xsl"?>
<>
...
...
<xsl:stylesheet id="style" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="1.xsl"/>
<xsl:include href="2.xsl"/>
<xsl:template match="xsl:*"/>
</xsl:stylesheet>
</>
,
, .
,
xsl:stylesheet
347
, ,
, XSLT.
version
XSLT 1.0,
<xsl:stylesheet> version="1.0".
XSLT, XSLT 1.0
.
, XSLT 1.1,
version="1.1" <xsl:stylesheet>,
, ,
1.1. , , ,
<xsl:script>,
.
<xsl:script>
version="1.1" <xsl:stylesheet> .
extensionelementprefixes
,
.
,
,
. <xsl:stylesheet>
.
, Saxon:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
extensionelementprefixes="saxon">
,
.
, <msxml:script>,
extensionelementprefixes, ,
,
.
, , xsl:extension
elementprefixes
, ,
.
,
, .
348
4. XSLT
, . XSLT
,
. ,
,
.
<xsl:fallback>,
,
, .
XSLT, ,
, ,
(, API
). ,
, ,
.
,
, .
.
extensionelementprefixes
, ,
. ,
(. ),
, $var1
$var2.
<: var1="{$var1}" var2="{$var2}"><xsl:fallback/></:>
,
, .
<xsl:fallback/>,
.
excluderesultprefixes
,
, .
,
, , exclude
resultprefixes. .
,
, .
XSLT, ,
. ,
.
xsl:template
349
,
, ,
match,
.
:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:po="http://accounting.org/xslt"
excluderesultprefixes="po">
<xsl:template match="po:">
<>
...
</>
</xsl:template>
</xsl:stylesheet>
excluderesultprefixes, po
, ,
<>.
<xsl:stylesheet>,
,
, xsl:excluderesultprefixes
.
, ,
.
.
<xsl:transform> . 366
xsl:template
<xsl:template> .
.
XSLT, 5.3
<xsl:template
name=
match=
350
4. XSLT
mode=
priority= >
<xsl:param> *
</xsl:template>
<xsl:template> ,
<xsl:stylesheet>.
match
, ,
.
, name.
name
. ,
match.
priority
(, ,
),
, ,
.
mode
.
<xsl:applytemplates>,
.
5.
6.
<xsl:param>, .
<xsl:template> match,
name, .
match, <xsl:template>
, <xsl:apply
templates>.
name, <xsl:template>
, <xsl:call
template>.
,
.
xsl:template
351
match
match , 6. ,
, .
$var.
:
<xsl:applytemplates>,
,
.
, match
? :
<xsl:variable name="x">
<xsl:applytemplates select="//item"/>
</xsl:variable>
<! >
<xsl:template match="item[$x]">
<xsl:valueof select="3"/>
</xsl:template>
<! >
, x ,
, <item> .
<xsl:applytemplates>
, ,
, <xsl:apply
templates> . 178.
,
match mode ,
mode <xsl:applytemplates>.
,
(
<xsl:import> . 256),
.
(
, ,
, ),
. priority,
, ,
match.
,
, .
, XSLT
, ,
.
,
352
4. XSLT
. ,
, .
name
name , ,
. ,
, (
, ,
<xsl:stylesheet>). , URI
: .
, <xsl:call
template>. name <xsl:calltemplate>
name <xsl:template>. ,
URI
, .
,
. . <xsl:import> . 256.
,
,
.
priority
priority , : 17, 0.5 3.
, XPath, 5,
.
priority ,
<xsl:applytemplates> .
:
, match.
, ,
<xsl:applytemplates>. <xsl:apply
templates> mode,
.
,
.
, , ,
.
,
.
, XSLT
353
xsl:template
,
, .
, ,
.
<xsl:applytemplates> . 178.
,
.
.
1 | 2
,
, 1,
2,
1 2
@
child::
attribute::
processinginstruction ( )
0.0
:*
@ :*
child:: :*
attribute:: :*
0.25
@
child::
attribute::
0.5
0.5
.
:
node(), text() * ,
,
: 0.5.
abc:* @xyz.* ,
,
,
, .
, @isbn,
, 0.0 ,
.
354
4. XSLT
, , : ,
[@isbn] /, [1]
, ,
, , ,
. , ,
, ,
//node().
, 1, 2, 3,
,
, .
, ,
,
, ,
.
mode
mode, , ,
.
<xsl:applytemplates> ,
, <xsl:apply
templates> mode,
mode.
:
, ,
(
),
, URI
.
, <xsl:template>,
<xsl:applytemplates> .
,
, ,
,
.
mode, match,
, ,
.
mode,
<xsl:applytemplates> , ,
,
<xsl:applytemplates>.
.
xsl:template
355
<xsl:template> ,
:
<xsl:applytemplates> ,
, .
, .
, <xsl:param>,
<xsl:template>.
<xsl:param>
. :
( <xsl:withparam>
), .
<xsl:param>: . <xsl:param> . 316.
. ,
<xsl:template> . XSLT
;
.
, ,
, .
,
.
, , ,
.
: ,
. , ,
, <xsl:message>,
.
,
,
.
<xsl:template> match,
, <xsl:applytemplates>.
, ,
XSLT,
. ,
,
356
4. XSLT
. ,
.
,
.
:
.xml.
, ,
<>, <>,
<>. ,
, <>.
, :
<?xml version="1.0" encoding="utf8"?>
<>
<>
<>
<> </>
<> (Wigmore)</>
<> </>
<>1998</> : <>
,
... , </>.
</>
<>
<>" " </>(
<>. . </>
) <> </>,
<></>.
</>
</>
</>
.xsl.
, ,
. , ,
,
,
xsl:template
357
.
( HTML):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body>
<xsl:applytemplates/>
</body></html>
</xsl:template>
<xsl:template match="">
<p><xsl:applytemplates/></p>
</xsl:template>
<xsl:template match="">
<font face="arial"><xsl:applytemplates/></font>
</xsl:template>
<xsl:template match="">
<xsl:text/>"<xsl:applytemplates/>"<xsl:text/>
</xsl:template>
<xsl:template match="">
<i><xsl:applytemplates/></i>
</xsl:template>
<xsl:template match="">
<u><xsl:applytemplates/></u>
</xsl:template>
</xsl:stylesheet>
, , <>.
, .
HTML ,
:
(Wigmore) 1998 :
, ... ,
.
(. . ) ,
.
(
XSLT .
, XSL Formatting,
,
358
4. XSLT
, HTML
.)
,
. ,
,
.
,
, ,
, ()
.
,
<xsl:foreach>, <xsl:if> <xsl:calltemplate>.
. 9.
.
, ,
, .
:
, ,
.
, .
.xml (. ).
+.xsl.
, <xsl:import>.
, , ,
, , .
  ( HTML
, ) ,
:
.
,
<!DOCTYPE> XML.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
359
xsl:template
<xsl:import href=".xsl"/>
<xsl:template match="/">
<html><body>
<xsl:applytemplates/>
<table bgcolor="#cccccc" border="1" cellpadding="5">
<tr>
<td><b></b></td>
<td><b></b></td>
<td><b></b></td>
<td><b></b></td>
<td><b></b></td>
</tr>
<xsl:applytemplates mode=""/>
</table>
</body></html>
</xsl:template>
<xsl:template match="" mode="index">
<tr>
<td><xsl:valueof select=""/> </td>
<td><xsl:valueof select=""/> </td>
<td><xsl:valueof select=""/> </td>
<td><xsl:valueof select=""/> </td>
<td><xsl:valueof select=""/> </td>
</tr>
</xsl:template>
</xsl:stylesheet>
. 4.10.
XSLT
. name,
<xsl:calltemplate>.
. <xsl:call
template> . 204.
360
4. XSLT
.
<xsl:applytemplates> . 178
<xsl:applyimports> . 174
<xsl:calltemplate> . 204
generateid() 7
xsl:text
<xsl:text>
.
XSLT, 7.2
<xsl:text> , .
disableoutputescaping yes | no
yes ,
( <)
,
XML <.
no.
. .
, <xsl:valueof>.
, ,
, , <xsl:text>
.
<xsl:text> ,
. ,
xsl:text
361
( , )
, :
<xsl:text>,
xml:space="preserve",
,
xml:space="default".
disableoutputescaping ,
, < (
<),
. no. yes
, ,
DOM, XML.
<xsl:text> :
.
.
, <xsl:text>,
.
XSLT. :
<xsl:valueof select=""/> <xsl:valueof select=""/>
,
, ( ).
, :
<xsl:valueof select=""/>
<xsl:text> </xsl:text>
<xsl:valueof select=""/>
,
,
, .
,
:
<xsl:valueof select="concat(, ' ', )"/>
concat() ;
7.
. , HTML ,
362
4. XSLT
. XML
.
, ,
,
. ,
, , , ;
, ,
.
,
<xsl:stripspace>, ,
, normalizespace(),
.
<xsl:text> ,
, . ,
:
<xsl:template match="stagedirection">
[ <xsl:valueof select="."/> ]
</xsl:template>
.
,
,
, .
,
<xsl:text>, :
<xsl:template match="stagedirection">
<xsl:text/>[ <xsl:valueof select="."/> ]<xsl:text/>
</xsl:template>
,
,
.
, <xsl:text> <xsl:value
of>, <xsl:text>
. , :
<! >
<xsl:text>[ <xsl:valueof select="."/> ]</xsl:text>
<! >
<
&
XML. XSLT :
< < <, <![CDATA[<]]>,
xsl:text
363
, XML.
, <. , <
: XSLT < .
,
. :
XML HTML, , ,
.
HTML,
HTML,
, < JavaScript
HTML.
XML, ,
XSLT . ,
&;
, .
,
, XML HTML. , ASP
Java Server Pages,
<% %>. ( Java Server Pages ,
, XML.)
XML HTML, disable
outputescaping <xsl:output>
method="text".
. ,
<xsl:element>
. , :
<! >
<xsl:template match=""/>
<xsl:if test='not(preceding::*[self::])'>
<ul>
</xsl:if>
<li><xsl:valueof select="."/></li>
<xsl:if test='not(following::*[self::])'>
</ul>
</xsl:if>
</xsl:template>
<! >
, <ul>,
, </ul>,
. , ,
<ul> </ul> :
XML XSLT
.
364
4. XSLT
, :
<xsl:template match=""/>
<xsl:if test='not(preceding::*[self::])'>
<xsl:text disableoutputescaping="yes"><ul></xsl:text>
</xsl:if>
<li><xsl:valueof select="."/></li>
<xsl:if test='not(following::*[self::])'>
<xsl:text disableoutputescaping="yes">/<ul></xsl:text>
</xsl:if>
</xsl:template>
XML XSLT,
, . ,
,
XML. , , , .
, .
, , ,
, .
<ul> </ul> ;
<ul> , .
, <ul>
<> , ,
:
<xsl:template match="[not(precedingsibling::*[1][self::])]">
<ul>
. . .
</ul>
</xsl:template>
<>,
,
, <>.
<>
,
. :
<xsl:template
match="[not(precedingsibling::)]">
<ul>
<xsl:calltemplate name=""/>
</ul>
</xsl:template>
<xsl:template name="">
<li>
<xsl:valueof select="."/>
</li>
xsl:text
365
,
. <>,
<>,
. , <xsl:foreach>
: ,
, <>,
.
1) , :
<xsl:valueof select=""/>
<xsl:text> </xsl:text>
<xsl:valueof select""/>
concat():
<xsl:valueof select="concat(, ' ', )"/>
2) , :
<xsl:output method="text"/>
<xsl:template match="">
<xsl:valueof select=""/>,<xsl:text/>
<xsl:valueof select=""/>,<xsl:text/>
<xsl:valueof select=""/>,<xsl:text/>
<xsl:valueof select="isbn"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:text/>
; ,
,
. <xsl:text>
, .
3) :
<xsl:text disableoutputescaping="yes">&nbsp;</xsl:text>
, #xa0 ( #160)
; :
<xsl:text> </xsl:text>
366
4. XSLT
.
<xsl:valueof> . 366
xsl:transform
<xsl:stylesheet>, . 337.
.
? ,
. ,
, ,
XSLT, , ,
. .
<xsl:transform
id=
version="1.0" or "1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
extensionelementprefixes=
excluderesultprefixes= >
*
</xsl:transform>
XSLT, 2.2
.
<xsl:stylesheet> . 337
xsl:valueof
<xsl:valueof>
.
XSLT, 7.6.1
<xsl:valueof select=
disableoutputescaping="yes" | "no"/>
367
xsl:value5of
<xsl:valueof> , .
select
, .
disableoutput
yes | no
escaping
yes ,
( <) ,
, XML
<. no.
; .
,
.
, :
, true,
false.
,
,
93.7. (
<xsl:number> formatnumber().)
, (
) . , .
.
:
; ;
;
( ).
. , ,
, . ,
.
,
, ,
, . //para
, <para> .
<para>,
<xsl:valueof select="//para"> .
, / ,
368
4. XSLT
.
, <xsl:valueof select="/"/> .
,
. ,
.
, ,
<xsl:copyof>, . 221.
disableoutputescaping ,
<xsl:text>. , <,
select ,
, disableoutputescaping
. .
<xsl:text> . 360.
<xsl:valueof>
( , ).
(,
<xsl:text>) <xsl:copy> <xsl:copyof>.
, <xsl:valueof>, <xsl:valueof
select="X"/> <xsl:copyof select="string(X)"/>!
<xsl:applytemplates> ,
<xsl:valueof select="."/>.
<xsl:valueof>
, <xsl:applytemplates>.
:
<xsl:template match="">
<>
<><xsl:valueof select="../@"/></>
<><xsl:valueof select="@"/></>
<><xsl:valueof select="@"/></>
<isbn><xsl:valueof select="@isbn"/></isbn>
</>
</xsl:template>
<xsl:valueof>
, ,
, . ,
,
:
<xsl:template name="">
<xsl:param name=""/>
xsl:value5of
369
,
$:
<xsl:variable name="$">
<xsl:calltemplate name="">
<xsl:withparam name="$a"/>
</xsl:calltemplate>
</xsl:variable>
$
,
.
disableoutputescaping
HTML XML ,
:
<>
<>
<> 178</>
<> 263</>
</>
< ="text/html">
<![CDATA[
<html>
<head><title>HTML </title></head>
<body> HTML !<p></body>
</html>
]]>
</>
</>
HTML XML
(Dave Raggett) html tidy (
http://www.w3.org/), HTML
XHTML. HTML,
CDATA,
. < >
, . XSLT
, HTML, ,
, , < >.
, :
<xsl:template match="[@='text/html']">
<xsl:valueof select="." disableoutputescaping="yes"/>
</xsl:template>
370
4. XSLT
, ,
XSLT; DOM,
.
<xsl:valueof select="."/>
<xsl:valueof select=""/>
<> .
<xsl:valueof select="sum(@*)"/>
, .
, "NaN".
<xsl:valueof select="$x"/>
$x
.
.
<xsl:copyof> . 221
<xsl:text> . 360
xsl:variable
<xsl:variable>
.
XSLT, 11
<xsl:variable>
( <xsl:stylesheet>),
.
name
371
xsl:variable
select
, ,
. ,
<xsl:variable>
5.
(). select,
<xsl:variable> .
<xsl:variable>
( ), , ,
( ).
select,
. select, <xsl:variable>
. select , ,
.
,
, , ,
. ,
.
, . XSLT 1.0
, .
XSLT 1.1
, :
.
,
,
, ,
XML. , ,
, :
<xsl:variable name="" select="''"/>
<xsl:variable name="" select='""'/>
:
<xsl:variable name=""></xsl:variable>
, ,
, ,
.
372
4. XSLT
:
<xsl:variable name="" select=""/> <! >
$ ,
, <>.
, ,
, .
, ,
.
XSLT 1.0, ;
.
, ,
:
<xsl:variable name="" select="255"/>
.
, , ,
, , :.
, ,
.
, URI
, . ,
, : :, ,
URI
. , URI
, URI .
,
, .
, .
:
x y, y ,
, x.
:
. .
X, ,
X:
, . ,
. .
,
.
, .
xsl:variable
373
. 4.11. :
XSLT
C, Java JavaScript ,
, ,
,
.
,
; ,
(
. <xsl:import> . 256).
(
XSLT 1.0 ,
). ,
,
,
. ,
.
.
,
.
, ,
.
, <xsl:param>.
.
,
.
374
4. XSLT
,
, .
, XSLT
. ,
, .
, ,
.
9.
XSLT :
, .
, ,
, , , .
,
, ,
.
, (
, ).
.
.
, ,
.
<xsl:variable name="" select="sum($/[.=$this]/@)"/>
<xsl:variable name=""
select="sum($[=$this]//@) $"/>
. . .
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="$"/></td>
,
, ,
$, .
, sum(), 7.
. ,
,
, : <xsl:valueof>.
,
: , ,
xsl:variable
375
. ,
;
.
,
.
, $ $ .
(, ) ,
: (a) (b)
.
,
, (
). ,
. ,
,
, :
<xsl:variable name="A" select="//[@='A']"/>
SQL.
<xsl:foreach>,
. .
:
.xml.
.
<?xml version="1.0"?>
<>
<>
<>The Magic Flute</>
<>Mozart</>
<>1791</>
</>
<>
<>Don Giovanni</>
<>Mozart</>
<>1787</>
</>
<>
<>Ernani</>
<>Verdi</>
376
4. XSLT
<>1843</>
</>
<>
<>Rigoletto</>
<>Verdi</>
<>1850</>
</>
<>
<>Tosca</>
<>Puccini</>
<>1897</>
</>
< ="Mozart">
<>Wolfgang Amadeus Mozart</>
<>1756</>
<>1791</>
</>
< ="Verdi">
<>Guiseppe Verdi</>
<>1813</>
<>1901</>
</>
< ="Puccini">
<>Giacomo Puccini</>
<>1858</>
<>1924</>
</>
</>
.xsl. ;
,
3.
<xsl:foreach>.
c (
). ,
. .
$c, <>
. current()
( 7), ,
.
<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
<body><center>
<h1></h1>
<xsl:foreach select="//">
<h2><xsl:valueof
select="concat(, ' (', , '', , ')')"/></h2>
<xsl:variable name="c" select="."/>
377
xsl:variable
<xsl:foreach select="//[=$c/@]">
<p><xsl:valueof select=""/></p>
</xsl:foreach>
</xsl:foreach>
</center></body>
</html>
. 4.12.
,
.
,
, ,
. :
<xsl:variable name="" select="/"/>
,
. ,
,
.
, //item <item>
, .
<item> , (
, )
$//item.
378
4. XSLT
,
, ,
:
<xsl:variable name="" select="document('.xml')"/>
<xsl:variable>, select, (
, XSLT 1.0).
,
.
. :
<xsl:variable name="">
<xsl:choose>
<xsl:when test="@">
<xsl:valueof select="@"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
$
@, ,
. ,
, ,
.
:
<xsl:choose>
<xsl:when test="@">
<xsl:variable name=""
select="@"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="" select="0"/>
</xsl:otherwise>
</xsl:choose>
,
<xsl:choose>!
, , ,
:
<xsl:variable name=""
select="concat(@, substring('0', 1, not(@)))"/>
, substring() 7.
xsl:variable
379
, , ,
<xsl:calltemplate>, ,
. .
: <xsl:calltemplate>
,
, .xml.
.xsl.
(), A; B; C D.
,
.
(
, ),
translate() ( 7),
. translate()
;
.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name=""
select="///"/>
</xsl:calltemplate>
</xsl:variable>
:
<xsl:valueof select="translate($, ',', ';')"/>
</xsl:template>
<xsl:template name="">
<xsl:param name=""/>
<xsl:foreach select="$">
<xsl:valueof select="."/>
<xsl:if test="position()!=last()">, </xsl:if>
<xsl:if test="position()=last()1"> </xsl:if>
</xsl:foreach>
</xsl:template>
380
4. XSLT
: Wolfgang Amadeus
Mozart; Guiseppe Verdi; Giacomo Puccini
XSLT 1.1 ,
, document(),
.
. :
.
,
.
. ,
, ,
.
, , .
:
<xsl:template match="/">
<xsl:variable name="">
<xsl:applytemplates select="." mode="1"/>
</xsl:variable>
<xsl:variable name="">
<xsl:applytemplates select="$" mode="2"/>
</xsl:variable>
<xsl:applytemplates select="$" mode="3"/>
</xsl:template>
,
,
<xsl:include>.
. document() 7.
XSLT 1.0
,
document(''),
. XSLT 1.1
,
,
.
,
. , 10
,
,
. XSLT 1.0 (
xsl:when
381
)
. XSLT 1.1
, . (
, ,
: , .
, ,
.)
, ,
<xsl:foreach> .
, ,
, :
<xsl:variable name="">
<></>
<></>
<></>
<></>
<></>
<></>
<></>
</xsl:variable>
:
<xsl:foreach select="$/">
<xsl:document href="{.}.xml">
. . .
</xsl:document>
</xsl:foreach>
, ,
.
.
<xsl:param> . 316
xsl:when
<xsl:when>
<xsl:choose>. , ,
, , ,
.
XSLT, 9.2
382
4. XSLT
<xsl:when test=>
</xsl:when>
<xsl:when>
<xsl:choose>, <xsl:choose> ,
, <xsl:when>.
test
<xsl:choose> :
<xsl:when>, test ;
<xsl:when> ,
.
<xsl:when> test,
, <xsl:otherwise>.
, .
( )
: ,
<xsl:choose>.
, test <xsl:when>
, , ,
, ,
.
XPath
. , :
, ,
,
,
383
xsl:with5param
, ,
. <xsl:choose> . 213
.
<xsl:choose> . 213
<xsl:otherwise> . 302
<xsl:if> . 253
xsl:withparam
<xsl:withparam>
<xsl:calltemplate>,
<xsl:applytemplates>. XSLT 1.1
<xsl:applyimports>.
XSLT, 11.6
<xsl:withparam> <xsl:apply
templates> <xsl:calltemplate>, ( XSLT 1.1) <xsl:apply
imports>.
name
select
,
.
5.
384
4. XSLT
(). select,
<xsl:withparam> .
<xsl:withparam>
<xsl:calltemplate>, <xsl:applytemplates> (
XSLT 1.1) <xsl:applyimports>.
<xsl:withparam> .
.
,
<xsl:variable>. select, ,
, select .
<xsl:param>,
<xsl:withparam>, ,
<xsl:withparam>, .
, ,
. <xsl:applytemplates>
(
).
, .
. ,
, ,
, :. ,
,
. ,
<xsl:param> , , URI
, .
, : ,
:,
URI . ,
URI , URI
.
, <xsl:withparam>
,
URI . ,
.
<xsl:withparam> ,
, ,
.
:
<xsl:withparam name="" select="$"/>
385
, "$"
, "$"
.
XSLT,
. ,
,
, XSLT
.
9, 10
.
<xsl:calltemplate> . 204.
.
<xsl:applyimports> . 174
<xsl:applytemplates> . 178
<xsl:calltemplate> . 204
<xsl:param> . 316
, , ,
! XSLT
,
.
.
XPath.
XPath XSLT
.
. XPath W3C
,
, XML (.
W3C XLink XPointer);
XSLT.
,
.
,
.
.
XPath,
http://www.w3.org/TR/xpath,
.
.
XPath XML XML Namespaces.
, , ,
.
,
, .
,
XPath.
, ,
387
. .
XPath :
, XPath XSLT, 7
, 8.
XPath
1.0, XSLT 1.1,
XPath. ,
XPath 1.0 (
).
XPath .
,
, or.
, and , or.
,
or. ,
, or,
.
or , (
or) . ,
,
. .
,
. ,
,
, ,
, 3 or '' ( true).
, , ,
; ,
. , 3|'' ( | )
,
, ,
| .
,
: .
,
, ,
388
5.
c ,
.
, ,
,
. ,
,
, .
. 394,
XPath.
,
, , .
, , (. 465),
, XPath .
,
, , ,
, ,
.
XPath
, , .
,
, ,
, .
,
, .
.
,
,
( ).
,
.
.
,
, , ,
. ,
, , ,
, ( =),
, and, .
389
. ,
, , .
*
*
, ,
. , ,
390
5.
XPath,
XML, , .
,
,
, .
. 407.
.
(AbsoluteLocationPath)
,
.
/ ? |
XPath, 2, 2
/
. , ,
, .
, UNIX,
. /
,
. /X
/X, /
, .
, //X,
. 390.
,
, document(),
,
.
(AdditiveExpr)
391
<xsl:variable name="
" select ="/"/>.
$.
, .
/pricelist
, <price
list>.
/*
, .
/child::node() ,
,
,
. (, , <?xml version="1.0"?>
; ,
XPath.)
/*/xsl:*
,
xsl:,
. (
XSLT, XSLT
.)
//
<>.
(AdditiveExpr)
.
|
+ |
XPath, 3.5, 25
392
5.
, +
.
.
,
. ,
, . , (
) , ( )
.
XSLT ,
, IEEE 754. .
2.
,
, number().
,
NaN ()
NaN.
$X + 1
$X.
last()1
, ,
.
@ @
.
count($) mod 5 + 1 5,
. 1 5.
(
. 428.)
42
42
,
.
(Argument)
,
.
393
(Argument)
XPath, 3.2, 17
XPath.
.
,
. , stringlength(..)
, docu
ment(@*,/) ,
, URI ,
URI URI.
XPath Arguments ()
. (parameters)
XSLT , .
, , Java JavaScript,
XPath
JavaScript. (
XSLT 1.1) 8.
, , concat()
.
, (,
count() sum()),
. , id() key(),
:
.
( : string(), number() boolean())
. 7.
XPath. , :
394
5.
count(@*)
id(string(@idref)) , ( )
ID idref .
not(isbn)
,
<isbn>.
,
./child::isbn.
generateid(/)
, .
(FunctionCall)
,
, .
(
( (, )* )?
)
XPath, 3.2, 16
: ,
7, XSLT
, , ,
,
8. ,
,
,
, ,
:.
, ,
.
:
, XPath,
(FunctionCall)
395
, XSLT.
XPath XSLT
.
( ),
, , ,
. XPath,
,
. ,
/, . @*,
.
,
node() comment(),
.
, .
.
; ,
, . con
cat(), , ,
.
XPath: , , .
XSLT 1.0,
,
.
, . ,
:
, systemproperty() , .
XSLT 1.1
: .
, ,
Java JavaScript.
,
;
, , ,
.
;
,
.
. ,
,
.
,
396
5.
, . , ,
; ,
, .
.
, ,
.
functionavailable()
. functionavailable()
, :
, , XSLT XPath
, ,
, .
true()
,
.
stringlength($x)
,
.
count(*)
,
* (
) ,
.
functionavailable(),
xt:intersection.
, ,
; ,
.
(Expr)
,
XPath.
397
(Expr)
XPath, 3.1, 14
XPath.
, .
XSLT XPath
:
.
{ }
,
.
3.
<xsl:applytemplates select="">
<xsl:copyof select="">
<xsl:foreach select="">
<xsl:if test="">
<xsl:key use="">
<xsl:number value="">
<xsl:param select="">
<xsl:sort select="">
<xsl:valueof select="">
<xsl:variable select="">
<xsl:when test="">
<xsl:withparam select="">
, . ,
( ,
). , ,
, OrExpr, .
XPath ,
.
398
5.
, or.
, , and ,
or, .
, or,
, , or.
XSLT ( ,
) ,
XPath
. (,
,
),
. , 2+2
XPath, <xsl:foreach select="2+2"/>,
XSLT , ,
.
, ,
, . ,
:
.
,
, :
,
.
,
, URI
. ,
, ( , ,
), ,
.
(, <xsl:if>
, <xsl:foreach> , ,
, ).
( ,
),
.
URI , , , ,
URI , . URL
XML, (
, <xsl:include>
<xsl:import>). XSLT 1.1 URI
xml:base, 2.
399
(Expr)
URI
URI, document(), 7.
,
, :
, .
, ,
,
. 2.
XSLT
. , (
systemproperty() key()) ( pre
fix:localname) , ,
, ,
.
,
XPath;
,
.
,
.
XSLT XPath
.
,
.
, (
) , XPath
. ,
,
.
.
, ,
, :
$x + ($y * 2)
$y ,
$x.
400
5.
// | //
,
<> <> ,
.
,
<> <>.
93.7
93.7.
(AndExpr)
,
.
| and
XPath, 3.4, 22
,
and.
and.
, ,
, .
,
. ,
.
,
boolean(), 7.
, .
XPath ,
, XPath
401
(OrExpr)
. ,
,
. , ,
. ,
:
<xsl:if test="functionavailable('my:trace') and my:trace(' !')"/>
my:trace(), ,
. my:trace()
, <xsl:if> .
, $x 3
8.
@ and @
,
. ( ,
,
, , .)
string(@) and
string(@)
,
, . (
,
, .
, ,
, .)
true()
,
.
(OrExpr)
,
, .
|
or
XPath, 3.4, 21
402
5.
, or.
or.
or :
, .
,
boolean().
, or
, .
( , .)
, XPath , NULL SQL,
,
. ,
.
$x = 5 or $x = 10
,
$x 5 10.
@name or @id
, name id
.
not(@id) or @id=""
, id
.
//[position()=1 or
position()=last()]
<>,
<>
.
(UnionExpr)
; , ,
.
|
|
XPath, 3.3, 18
(UnionExpr)
403
, |.
:
, ,
.
, .
.
,
$a | $b,
, ,
2.0 | "". , .
*/ | */
,
,
<> <>.
[not(@)] | <>
[@='Wrox'] ,
Wrox. ,
or.
(.|..)/
<>,
.
sum((|)/@)
<> <> .
(//* | //@*)
[.='2000']
,
,
2000.
XPath 1.0 ,
, .
,
.
404
5.
$p $q,
:
$p [ count( . | $q) = count( $q ) ]
$p, $q.
$q, $q
, $q.
, , $p,
$q:
$p [ count( . | $q) != count( $q ) ]
(RelationalExpr)
.
: , ,
, . ,
.
|
< |
> |
<= |
>=
XPath, 3.4, 24
XPath
, :
<, >, <= >=.
.
XPath ,
.
XSLT, XML
. <,
,
(RelationalExpr)
405
<.
> >,
.
. XPath
.
10 < $x < 30
, .
, : (10 < $x),
,
30.
,
number()
, IEEE 754.
, , 1.0 < 3.5 , 1.0 > 3.5
. ,
, , ,
1.0 < (2.0 div 0.0) ,
2.0 div 0.0 . ,
(NaN),
. , '' <= '' ,
NaN, NaN <= NaN
.
,
, .
, ,
, ,
: <, <=, > >=. ,
.
,
,
, ,
. P
, :
0, , 1,
. Q
: 0
1 .
, P Q.
, ,
. ,
// < 5.00 ,
<>, , ,
5.
406
5.
, ,
. , // <
'5.00' , <>,
, , 5.
,
.
,
; , , $p
< $q $q > $p.
, ,
. ,
P, Q, , number(P)
number(Q). ,
, min() max()
.
M < N
M <= N
M > N
M >= N
,
. , @ > 5.00 ,
5.00; ,
5.00.
,
, .
,
, , ,
:
<xsl:variable name="limit">142</xsl:variable>
,
:
<xsl:variable name="limit" select="142"/>
:
<xsl:variable name="limit" select="'142'"/>
(PathExpr)
407
count(*) > 10
, 10 .
sum()
< 10000
,
<> .
position()
< last() div 2
,
,
.
not(//@temp
<= 0.0)
, temp
.
(PathExpr)
( ),
.
, , ,
, .
|
|
/ |
//
XPath, 3.3, 19
.
,
.
:
, ,
,
.
408
5.
, ,
, , ,
, , ($a | $b),
,
.
, /
, ,
,
, .
, //
: ,
// /descendantorself::node()/.
,
<> .
[@id]
,
<> ,
id.
/@id
,
id <>
.
,
, .
/*/
,
<>
( ).
,
, , .
.
$[23]
,
. 23
, $.
document('lookup.xml')
,
, , .
XML, URI lo
okup.xml.
key('',
' ')
[@
='']
,
,
. ,
,
, .
(EqualityExpr)
409
(//|//)
[='']
,
.
<> <>,
<>,
.
$/
<
> , $.
$[3]/
<
> ,
$.
(//|//)
//
<>
<> <>.
((//|//)// (
)[last()]
) <>,
<> <>.
, , ,
XPath .
, ,
, ,
,
UNIX.
// ro
ot(), ,
(/ )*,
.
/, /
./ .
(EqualityExpr)
.
: (<, <=,
> >=) . 404.
|
= |
!=
410
5.
XPath, 3.4, 23
, = () !=
( ).
= !=.
( )
. ,
,
.
=
XPath, ,
.
:
, $X=$X .
, $X ,
.
, $X!=3 ,
not($X=3). $X ,
, 3,
, 3.
, ,
: $X=$Y , $Y=$X.
.
, $A = $B = $C .
, , .
, ($A=$B)=$C, ,
$C $A $B.
, , 2=1=0 ,
2=1 ,
, 2=1 boolean(0).
411
(EqualityExpr)
,
: , .
, :
,
,
, ,
,
:
=
,
. ,
,
.
,
,
NaN;
,
NaN.
,
,
, .
,
,
NaN;
,
NaN.
,
IEEE 754.
, ,
number(),
IEEE 754.
,
,
, .
, ,
number(),
IEEE 754.
,
Unicode.
IEEE 754 .
2. ,
, .
( ,
) != ( )
=: =
, != , .
,
. ( , ,
412
5.
@HREF, ,
.) =
!= . ,
, .
= ()
!= ( )
,
,
,
,
.
,
, ,
,
.
,
, ,
number(),
IEEE 754.
,
,
,
number(),
IEEE 754.
,
,
, ,
.
.
, ,
,
.
, ,
,
.
,
.
,
,
,
.
, ,
,
.
,
,
.
, $N '',
$N=''
: , $N n, string
value(n)=''. , $N!=''
: ,
$N n, stringvalue(n)!=''. $N
"" "",
$N='' $N!='' , ,
'', . $N ,
$N='' $N!='' , ,
'', , .
(EqualityExpr)
413
, ,
, .
.
:
, , XML:
<>
<><></><></></>
<><></><></></>
</>
, ,
<>, :
<xsl:variable name="" select="//"/>
, :
<xsl:if test="$ = ''"/>
, $
<>, "".
<> "",
"". ,
"", :
.
.
, .
.
. .
: $N
, $N=$N ,
,
.
, , ,
<xsl:if test="@!= ''"> ,
<xsl:if test="not(@ = '')">. :
, ,
.
, !=, ,
. not(x=y),
.
, !=,
:
. , <xsl:if test="not($//!=1.0)">
414
5.
, $//
, 1.0.
,
, . , ..=/
,
. ,
,
,
. , :
,
,
, .
,
, parent::*[not(..)]:
, , .
, ,
, generate
id(..)=generateid(/). generateid(),
7, ,
. ,
| count(): count(..|
/ )=1 and .. ,
.
and .. ,
, , .
,
.
,
.
. /
, docu
ment() (
). ,
<xsl:variable>
<xsl:param> select.
,
XML,
,
:
.
, ,
, , ,
415
(EqualityExpr)
.
, :
<xsl:variable name=""></xsl:variable>
, , :
<xsl:variable name="" select="''"/>
$='' .
$=''
, ,
, :
<xsl:variable name=""> <emph></emph> </xsl:variable>
:
( ),
<emph> .
.
= != $
, .
:
= != , ,
. :
= ()
!= ( )
,
, ;
,
.
,
,
;
,
.
,
,
number(),
IEEE 754.
,
,
number(),
IEEE 754.
, ,
.
.
, ,
, ,
.
.
416
5.
, ,
:
<xsl:variable name=""></xsl:variable>
, :
<xsl:variable name="" select="''"/>
: ,
. $
=false() , $ ,
, $ , .
, XSLT 1.1 ;
,
.
@ = 3
,
3. ,
3, , ,
3.00.
.
@ = @ ,
. 3,
3.00, . ,
.
, number(),
7,
.
@ != $x
$x ,
; ,
.
, . ,
.
$x ,
, ,
; ,
.
(NCName)
(NCNameChar)
. XPath
XML Namespaces Recommendation.
(NCName) (NCNameChar)
417
NCName, nocolonname ().
,
.
( | _ ) () *
| | . | | _ |
|
XML Namespaces Recommendation
XPath :
, . 436, ,
. 420.
,
XML,
XML.
, XSLT
Unicode,
. . .
418
5.
XML, XPath ,
XML Namespaces. XPath
, XML XPath
, XML ,
XML Namespaces, , ,
.
XML,
,
. , Unicode
, ,
.
:
A
a
_systemid
iso88591
.
Straenberfhrung
_...__..._
(OperatorName)
, .
XPath, 3.7 (Lexical Rules), 33
(FunctionName)
419
XPath;
, . ,
, , .
,
, .
.
XML <div> (
, XHTML),
, ancestor::div
div. , div ( and, or, mod)
,
: ,
, : @,
::, ,, (, [ .
$x = 5 or $x = 10
,
$x 5 10.
position() mod 2
,
, .
floor(
name
stringlength(@name) div 2) .
@name and @id
, name id.
(FunctionName)
, ,
.
; ,
, .
,
( )
, XPath
XSLT.
420
5.
XPath, 3.7 (Lexical Structure), 35
, ,
: comment, text, processing
instruction node. ,
.
( 7)
. ,
,
. ,
,
, .
concat
stringlength
namespaceuri
saxon:intersection
xt:nodeset
irs:gettaxrate
(NameTest)
, ,
.
XPath, 3.7 (Lexical Rules), 37
* |
: * |
(NameTest)
421
, , ,
.
:
:*.
XPath,
XSLT. , <xsl:preservespace>
<xsl:stripspace> ,
, .
.
* . (
*
child::*,
. ,
* ,
, , attribute na
mespace, .)
, :
<xsl:copyof select="@*[not(self::)]"/>
, .
? self ,
,
self:: . , :
<xsl:variable name="" select="generateid(@)"/>
<xsl:copyof select="@*[generateid(.)!=$]"/>
xyz:* ,
xyz.
, ,
URI .
xyz:item ,
xyz item.
, ,
URI .
item ( )
item URI .
.
422
5.
,
xmlns="some.uri", <item>
XPath //item,
xmlns="some.uri".
, XPath
. ,
xmlns:x="some.uri", , : //x:item.
. * ,
child::*,
,
.
xt:*
,
xt. xt:* ,
child::xt:*,
,
xt.
URI .
wrox: ,
wrox .
(NodeTest)
.
|
( ) |
processinginstruction ( )
, processinginstruc
tion(); ,
.
, XPath,
. ,
, ,
, node() com
ment(), ;
,
.
(NodeTest)
423
XPath, 2.3, 7
/ ,
.
, .
, ,
, . attribute
; namespace ;
.
node() .
node(), ,
.
processinginstruction(), comment() text()
.
attribute namespace,
. , ,
,
, .
. (,
ancestor parent) ,
, node().
, , ,
/.
<>,
attribute ( attribu
te:: @),
, namespace (, namespace::),
.
:
.
, .
424
5.
,
, xmlns:="
uri". URI
, .
MathML:*
,
MathML.
, .
,
, xmlns:MathML="uri".
,
attribute ( attribute::*
@*), , namespace (
, namespace::*),
.
text()
.
processing
instruction()
. , XML
,
.
processing
instructi
on('ckpt')
( XML
, PITarget) ckpt: , <?ckpt
=?>.
node()
(Literal)
.
,
, ,
, :
, , ,
, ,
.
.
,
.
(Literal)
425
, ,
XML
,
XPath. ,
	, 
 
.
XPath, 3.7 (Lexical Structure), 29
:
. 422.
(,
,
). .
,
, ,
.
; , con
cat(), 7.
,
XML , XPath.
, XSLT, XPath
XML . XML
, XPath
,
; ,
, XPath
.
, . ,
, message[text="I wont"],
:
<xsl:variable name="msgtext">I won't</xsl:variable>
426
5.
: message[text=$msgtext].
, XPath ,
:
<xsl:variable name="html" select="'netscape'"/>
, netscape
, <netscape>
. ,
, , ,
, .
:
<xsl:variable name="html">netscape</xsl:variable>
(
, ),
. (
.)
XPath :
''
""
"'"
' ""'
, XPath,
XSLT,
,
,
XML. :
<xsl:valueof select='"'"'/>
<xsl:valueof select="' ""'"/>
, , :
<xsl:valueof select='" """'/> <! >
, XML ,
XPath, XSLT, :
" """
. ,
, concat(), .
(LocationPath)
427
(LocationPath)
, ,
, (),
().
XPath, 2, 1
,
,
.
,
. (
,
, ,
.)
//
[3]/
[2]
<>
<> <>,
. <>
,
.
//
,
<>. (
.)
.
, .
428
5.
//
<> <>,
<>, , ,
.
[not(@
=precedingsib
<> ,
ling::/@)] ,
<>.
, <>
.
SQL SELECT DISTINCT.
(MultiplicativeExpr)
,
.
XPath, 3.5, 26
|
|
div |
mod
, *,
div mod,
.
.
,
XPath ,
(MultiplicativeExpr)
429
, * XPath :
, ,
.
/ ,
,
.
XPath ,
, ,
.
, ,
, number().
,
NaN (),
NaN.
XSLT ,
.
IEEE 754, 2.
,
. ,
, :
5 mod 2
5 mod 2
5 mod 2
5 mod 2
ceil(count(item) div 3)
<item> , . (,
,
.)
@*2
430
5.
(AxisName)
.
ancestor |
ancestororself |
attribute |
child |
descendant |
descendantorself |
following |
followingsibling |
namespace |
parent |
preceding |
precedingsibling |
self
XPath, 2.2, 6
(axis) ,
( ) ,
.
.
ancestor
,
.
, , ;
.
ancestororself
, ancestor,
, .
attribute
,
, .
.
(AxisName)
431
child
. , ,
. ,
,
, ,
, .
descendant
,
.
. ,
, descendant ,
, ,
, .
descendantorself , descendant, ,
.
following
, ,
, .
, ,
, , ,
.
.
followingsibling ,
,
. ,
, followingsibling
.
namespace
,
,
; .
.
(xmlns="x" xmlns:y="z")
,
, ,
.
,
, 2.
parent
. , parent .
preceding
, ,
, , .
, ,
, ,
,
432
5.
preceding
.
.
precedingsibling
,
. ,
, precedingsibling
.
self
.
.
.
,
, , .
,
.
ancestor
ancestororself
child
(AxisName)
descendant
descendantorself
following
followingsibling
433
434
5.
parent
preceding
precedingsibling
self
. 465.
(Operator)
435
. .
ancestor::*
, .
child::node()
.
: node().
attribute::
.
: @.
, .
namespace::*
,
.
, .
self::item
, <item>,
.
, , *[not(self::item)]
,
<item>.
,
.
(Operator)
, .
|
|
/ | // | | | + | |
= | != | < | <= | > | >=
XPath, 3.7 (Lexical Rules), 32
,
= .
436
5.
XPath; ,
. , ,
, .
, .
( and or),
,
.
,
XPath; XSLT <
> < > . / //
, :
, .
and or div
* / = != <
(MultiplyOperator)
: .
,
XPath ,
, * XPath :
, ,
.
XPath, 3.7 (Lexical Structure), 34
(RelativeLocationPath)
437
. . 428.
XPath , *
,
: @, ::, ,, (, [ .
.
item[$x * 2]
<item>,
$x.
***
. (
,
.
child::*.)
(RelativeLocationPath)
,
, .
,
.
|
/ |
XPath, 2, 3
438
5.
,
.
,
,
,
.
,
/ //.
,
:
( ( / | // ) )*
, // .
,
, . ,
(
) descendantofself::node(),
. , A/descendantorself::node()/B
A//B.
. 450.
/ . 465.
ancestor::
,
. ,
<>.
,
: .
,
<>.
descendant::/
@
, .
,
<>;
, .
[1]/[3]
, ,
. <>
;
<>,
<>.
(PrimaryExpr)
439
///
<>, <
>, , ,
<>,
<>, .
.//
<>,
.
(PrimaryExpr)
, , , .
.
|
( ) |
|
|
XPath, 3.1, 15
,
.
, .
,
, 17[1] ''[3]
. ,
, ,
, ,
.
440
5.
:
.
, [1],
[1], , ,
,
[1].
, , ()[1]
.
, .
:
ancestor::*[1]
ancestor, , .
(ancestor::*)[1]
( )
, ancestor::*,
.
///[1]
<>,
<> <>.
(///)[1] ,
<> <>.
23.5
''
$var
contains(@, '#') .
(position() + 1)
(QName)
,
.
( : )?
(QName)
441
XML Namespaces Recommendation
XSLT, XPath.
(, <xsl:preservespace>
<xsl:stripspace>),
, , , ,
.
, ,
. ,
, <xsl:element> <xsl:attribute>,
, key() formatnumber()
( ),
.
,
, ,
.
XPath
.
,
.
:
<xsl:applytemplates select="math:formula" xmlns:math="http://math.org/"/>
,
, .
math:formula, (
), ,
URI http://
math.org.
,
URI . ,
,
XML Namespaces
442
5.
, URI. :
URI,
.
XPath URI
, URI .
.
, :
<html xmlns="http://www.w3.org/1999/xhtml">
:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:template match="html">
match="html" ,
<html>?
( xmlns="")
, ,
.
:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:template match="xhtml:html">
, ,
, URI.
HTML:
, , URI
URI HTML .
443
(Predicate)
(Predicate)
,
.
[ ]
XPath, 2.4, 8
:
.
, ,
.
:
[3]
[3] ,
./child::.
<> .
$[3]
[3]
$. ,
,
, .
.
, ,
. :
/[1]
[1]
, ./child::.
<> <>
.
444
5.
(/)[1] , [1]
, /.
<>,
<> <>,
.
[ ] ,
/. ,
. ,
. .
.
, XPath
; , [$p]
. .
,
,
boolean() . ,
, [@] ,
, .
:
@ ,
[boolean(@)].
, [number(@)].
[P]
[position()=P],
[position()=@].
2,
. , ,
, .
.
:
(, .)
, .
( position())
.
( last())
.
,
, .
(child, descendant, descendantorself, following, followingsibling)
, position() .
445
(Predicate)
,
, , ,
.
, , ,
. ,
.
, ,
. ,
:
(
*),
( ).
:
.
and. ,
. ,
( position())
( last()) ,
. ,
.
[=". . "][1] , . . .
[1][=". . "] , ,
. . .
[position()=1
and =". . "]
, ,
. . .
,
.
446
5.
[1]
<> .
[last()]
<>
[position()!=1]
<> ,
.
[@]
<> ,
.
[string(@}] <> ,
, .
[* or text()]
<> ,
.
(PredicateExpr)
, .
XPath, 2.4, 9
:
, XPath.
,
, ,
, .
boolean().
, , ,
. , XSLT,
, , ( XSLT 1.0
(ExprWhitespace)
447
, <xsl:variable>
4):
<xsl:variable name="">3</xsl:variable>
,
, :
<xsl:variable name="" select="3"/>
( select="'3'",
); :
<xsl:valueof select="[number($)]"/>
:
<xsl:valueof select="[position()=$]"/>
(
, ,
).
; :
[]
;
, <>
<>.
[
@='']
[
,
substringbefore(.,':')]
, , sub
stringbefore() .
[not(=
precedingsibling
::)]
,
,
.
.
(ExprWhitespace)
,
XPath.
448
5.
XPath, 3.7, 39
S XML Recommendation.
,
XPath.
XML:
,
, .
XPath
. ,
,
. ,
XPath , . ,
self::x (
, ), xsl:*
,
. , xsl:* ,
, , ,
.
XPath ,
.
, ,
.
, ,
;
,
.
,
or, and, div mod. 5 mod 2
mod , 5mod
, mod ,
mod2
.
(AbbreviatedAbsoluteLocationPath)
449
XPath ,
XML,
.
, .


,
.
(AbbreviatedAbsoluteLocationPath)
, .
//
XPath, 2.5, 10
// ,
; (relative location
path) .
, XSLT
, .
, .
, , <>
, /*/
, //. ,
.
450
5.
//
<>.
//[@=' <>,
']
.
//*/*
,
, , ,
. *
, .
///
<> <>.
//X /descendantorself::node()/X.
//[1] /descendantorself::node()/[1],
<> ,
<> .
<> ,
/descendant::[1] (//)[1].
(AbbreviatedRelativeLocationPath)
,
//,
, .
//
XPath, 2.5, 11
.
//, ,
, XSLT
(AbbreviatedRelativeLocationPath)
451
.
, . ,
, ,
$A/*/B $A//B. ,
.
, $//,
$/descendantorself::node()/. :
$
, <>.
, ,
$/descendant::, ,
, :
: // /descendant::
$//[1] $/descendant::
[1]:
$//[1] $/descendantorself::node()/
[1], <>,
<> $.
$/descendant::[1] <> (
),
$. :
($//)[1].
, :
<>
<>
< ="12"/>
< ="13"/>
</>
< ="14"/>
<>
< ="15"/>
< ="16"/>
</>
</>
$ <>
, $//[1] 12,
14 15, $/descendant::[1] ($//
)[1] 12.
452
5.
//
<>,
<>, , ,
.
, ,
. 394.
.//
<>,
.
document('lookup.xml')// <> ,
URL lookup.xml. docu
ment() 7.
$//*/@
,
,
$.
.//..
, ,
//,
, ..,
. ,
,
.
(AbbreviatedAxisSpecifier)
,
, .
@ ?
: , @ .
,
.
XPath, 2.5, 13
453
(AbbreviatedStep)
@,
, ,
. @
attribute::,
child::. . 455,
, , (
. 465),
, .
, A/@B B
A, A/B B A.
self::.
self::, ,
<>, self::@,
, .
, , ,
, @,
, ,
.
.
: ./attribute::.
, , ,
, ,
, ,
. : ./
child::.
(AbbreviatedStep)
.
. | ..
XPath, 2.5, 12
454
5.
: ., , ..,
. ( .
. 394.)
self::node() parent::node(), .
. , , ,
/, ,
, . .
:
// , .//A,
( ) <A>,
. . ,
//,
.
, ,
. ,
.=3 stringlength(.),
, XSLT <xsl:valueof select="."/>,
.
. , ./,
.
..
, , ../@
. ..
,
. , //@/..
, .
//*[@].
, , , (
, /.. ,
not(..) ,
). 2, ,
, ,
. ,
ID, //@ID/.. ( //*[@ID]
, , , ).
, XPath
455
(AxisSpecifier)
.
.
, . ..
, , <xsl:if test="
.[@='']">. XSL Microsoft WDxsl,
,
. XSLT
<xsl:if test="@=''">.
XSLT
<xsl:valueof select="."/>
<xsl:valueof
select="../@"/>
.
(AxisSpecifier)
, .
:: |
XPath, 2.1, 5
,
, .
@, ,
, ,
child::.
.
, .
. 401.
456
5.
ancestor::
ancestor.
precedingsibling::
precedingsibling.
attribute.
child. (, !)
(VariableReference)
XSLT.
XPath, 3.7 (Lexical Rules), 36
,
,
, . ,
name
<xsl:variable> <xsl:param>. ,
URI , .
, $
.
,
<xsl:variable> <xsl:param> ( <xsl:param>,
<xsl:withparam>
). : , ,
, , XSLT 1.0,
. ,
. ,
: , ,
, ,
( test <xsl:if>),
(VariableReference)
457
; ,
, ,
.
, . ,
,
, , select <xsl:applytemplates>
<xsl:foreach>.
XPath, :
: , , ,
.
, , ,
.
.
, :
<xsl:sort select="$"/>
$ XPath,
. ,
, , , ,
,
.
, , ,
, :
<xsl:sort select="*[name()=$]"/>
,
evaluate(),
( Saxon Xalan).
XPath .
,
, XSLT
DOM. A , ,
MSXML3.
$x
$
$ALPHA
$mynsprefix:param1
$p
458
5.
(NodeType)
.
comment |
text |
processinginstruction |
node
,
, .
,
,
. XML
text node, XPath
text node. ,
text().
XPath, 3.7 (Lexical Rules), 38
(, ,
), .
comment, text processinginstruction
: . node
. ,
,
, node(). ,
, child::node().
,
, : , ,
. ,
,
/.
, attribute namespa
ce: ,
. ,
, ,
(UnaryExpr)
459
,
*.
parent::node()
,
. pa
rent::*, ,
. parent::node() ...
//comment()
child::text()
.
text().
@comment()
, :
attribute, , ,
.
(UnaryExpr)
.
XPath, 3.5, 27
. ,
( ) ,
.
0 ,
IEEE 754.
(,
0). ,
460
5.
+1, ,
:
.
( ) , .
.
, ,
.
, , ,
$a|$b. ,
$a $b, ,
.
( ).
.
(, ,
).
,
.
,
.
1 1
,
0. ,
.
(FilterExpr)
, ,
.
XPath, 3.3, 20
(FilterExpr)
461
,
,
, .
, ,
[@=''] [position()=1].
XPath
, , 23, '' true().
,
.
; , ,
.
, .
(, [1] [last()1])
(, [count(*) > 5] [@ and @]).
,
, (
boolean()) .
N [positi
on()=N]. , , [1] [position()=1],
[last()] [position()=last()].
,
position() ,
. , $[1 or last()]
$[position()=1 or position()=last()],
1 or last()
, ( ). ,
[../@] [positi
on()=../@], ../@ ,
.
, , :
, $x[count(*)] ,
.
, XPath
. ,
, .
:
462
5.
(, .)
.
( position())
, ,
.
( last()) ,
.
, , $
[self::h1] [last()]. ,
$ ( ,
). [self::h1]
$.
, .
self::h1 ,
: .
<h1>,
. .
, , ,
, . ,
$, <h1>.
<h1>. [last()]
: <h1> .
, ,
[position()=last()], (
) . ,
$ [self::h1] [last()] :
<h1> $, .
, , $ [last()]
[self::h1], : ,
$, <h1>.
, ,
XPath, ,
, :
. , $[1] ,
[1] ,
. ,
, ,
(, /[1]
[1] )
(
,
).
463
(Digits)
. .
$[23]
,
. 23
, $,
.
document('lookup.xml')
. ,
URI lookup.xml.
key('', '
,
')[@loc=''] . ,
,
,
.
(//|//)
[='']
, .
<> <>,
<>,
.
document(//@href)
[][1]
, URL,
href ,
<>,
. ,
, ,
,
, .
(Digits)
0 9.
,
.
[09]+
,
, 0 9.
,
464
5.
;
.
XPath, 3.7 (Lexical Structure), 31
0 9.
,
,
.
89
,
.
3.14159
,
. 3,
14159.
(Number)
( ).
(. ?)?
.
XPath, 3.7 (Lexical Rules), 30
465
(Step)
,
.
:
839
10.
3.14159
.001
, XSLT
.
2 .
round(), ceiling() floor(), 7.
,
, ,
, ,
.
, XPath
;
1000000, 1.0e6.
(Step)
,
; , A
.
XPath, 21, 4
466
5.
:
. , ,
.
.
, /.
;
,
,
.
; ,
self::node()/child::,
/descendant::
root()/descendant::, root()
.
XPath
,
. S
S(X) N, X N
. /
map(A, F) U, A
F U,
F
A.
, ancestor::node() .
, $n/
ancestor::node(), ,
$n.
.
,
: , .
, ,
.
,
,
,
.
,
.
,
,
. ,
. ; ,
,
467
(Step)
, ( /[3])
.
[3] ;
,
.
:
1. , .
2. (
).
3. ,
, , .
4. ( )
. (
.) ,
( position()) ,
, (
last()) ,
. , [2] [last()1],
[position()=2]
[position()=last()1] .
5. 3 4 .
child::
<>
.
child::.
attribute::
attribute::.
ancestor::xyz:*
,
xyz.
*[@]
.
text()
[startswith(.,'The')]
,
The.
468
5.
,
.
@comment()
attribute::comment(),
attribute.
attribute
,
, ,
.
(ExprToken)
XPath.
; ,
.
( | ) | [ | ] |
. | .. | @ |
, | :: |
|
|
|
|
|
|
|
XPath, 3.7 (Lexical Structure), 28
, .
(ExprToken)
469
,
. , :
.
.
, child::xsl:* : child, :: xsl:*.
,
. ,
, : child::xsl:*.
, ,
,
, , . , ,
child::node() , ::
.
,
. ,
,
, $x div 2 .
.
XPath
,
.
.
, .
, .
item
mynamespace:*
.
.
$
.
$.
93.7
" "
. ,
,
.
470
5.
XPath XSLT
,
. XPath XML ,
SQL SELECT ,
,
.
XSLT XPointer
,
DOM XPath
DOM.
.
XPath
, .
, XSLT,
6 .
XSLT.
(patterns) XSLT:
match <xsl:template>
, .
match <xsl:key>
, .
count from <xsl:number>
.
,
, .
match <xsl:template>,
, . ,
<xsl:template match="abstract"> ,
<abstract>.
,
:
<>.
<>,
<>.
speech[speaker=
""]
<speech>,
<speaker>, .
/[1]
<>,
<> <>.
472
6.
,
,
.
, ,
.
, , ,
, .
XPath,
, , ;
.
XPath, XPath
. ,
2+2 ?
.
XPath 1.0,
, XSLT. ,
XPath XPointer
, DOM
DOM. , , XSLT Re
commendation ( 5.2 )
.
XSLT
XPath ,
. XSLT
,
,
.
. ,
,
./child:: : <
> .
, <>?
,
. ,
, ,
,
.
.
473
XPath, . ,
XPath.
, ,
, ,
. ,
, , ,
, .
. XPath
<> .
<>, , ? ,
. ,
<>,
: ( N)
, (
, A), , A
, ,
N .
A. N.
, <>
, , ,
./child::
, <>.
, , ,
.
XSLT
,
. , ancestor::*[3],
.
, ,
, :
child attribute (
(AxisName) 5).
, XSLT A (
)
(N), N.
(
):
N P ,
A, N N,
P A ,
, N.
474
6.
, A
. ,
, .
position() last() ,
.
,
N P: , N
, P
XPath, .
, N, ,
;
. :
<> ,
<>,
( ./child::
) , <>.
// <>,
<>,
// <>
<> <
>.
/,
/
.
100 @[.=100],
, ,
@[.=100].
XSLT ,
.
,
,
.
,
. , ,
node() , . node()
./child::node(),
, .
,
(.
2), node()
.
475
(
), , ,
position() last().
, [1] ./[positi
on()=1]. <>
, , ,
( ). [1]
<>, <>
. *[1][self::]
,
<>, [last()!=1]
<>,
<>.
, //,
,
, <>,
<> , ,
.
, ,
, XSLT
, .
//, ,
:
, <>. ,
.
, , <>.
, .
,
, , speech[speaker='']
, , :
, <speech>. ,
.
, <speaker>
. , .
476
6.
,
, , , .
, , , ,
, .
, , [last() 1],
<>, <>
. XSLT,
,
<>,
, <
> , .
<>
,
. [1]
[last()] ,
, .
, , ,
, . ,
,
, ,
.
, .
.
, ,
, .
<xsl:template> 4.
.
, , 5 .
ChildAttribute
*
*
*
477
(Pattern)
ID
*
,
, ,
, .
:
477
478
480
482
ChildAttribute
487
ID
488
, 5.
(Pattern)
XPath.
,
.
(, , ).
|
|
,
, |.
.
match <xsl:template> (. 4)
match <xsl:key> (. 4)
from count <xsl:number> (. 4)
478
6.
, , |
,
A | B, A B .
.
| |
,
<>, <> <>.
/ | *
,
.
(LocationPathPattern)
, , ,
/ ID
, .
( , ).
/ ? |
ID
( ( /|// ) ) ? |
// ?
XSLT.
.
/ |
|
/ |
// |
ID |
ID / |
ID //
(LocationPathPattern)
479
. 480,
ID . 488.
(. . 477)
, XSLT,
:
/
,
.
,
.
// ,
.
//
, .
,
:
<xsl:template> 4.
ID
ID .
ID /
,
ID
.
ID //
,
ID
.
/ .
, . ,
(
document(), 7),
/ .
.
(. <xsl:applytemplates> 4)
, .
480
6.
, /item, <item>,
.
, ,
.
/@ ,
, ,
.
. 480 ID . 488.
/*
(
). ,
(.
2),
, .
<>,
.
//
<>,
; ,
<>.
<>.
id('1')
'1'.
id('1')//*
,
ID '1'.
ID
(RelativePathPattern)
, ,
.
,
.
XPath.
(RelativePathPattern)
481
|
/ |
//
,
, / //.
. 482.
,
( , ), .
, .
,
( , ), ,
.
, , ,
.
,
( , ), ,
, .
, , ,
.
,
,
, , ,
. , ,
,
. , ,
.
, ,
, A/B
, B[parent::A], A//B ,
B[ancestor::A]. ,
/ // .
482
6.
, , ,
.
<>.
,
, /.
<>, <>.
//
,
, //.
<>, <>.
/// ,
<>,
<>,
<>.
(StepPattern)
,
. ,
.
XPath.
ChildAttribute
*
ChildAttribute . 487.
5.
ChildAttribute
, . 487, ,
( ).
, ,
@ attribute,
, ,
text() comment(),
, ,
.
(StepPattern)
483
ChildAttribute attribute:: (
@) child:: ( ).
, ,
:
.
,
.
child,
(, , * svg:*), .
child, (
, comment() text()), .
node(), child: ,
, . ,
node(),
child::node(), ,
,
.
attribute,
(, @, @* @svg:*),
.
attribute,
(, @comment() @text()), ,
attribute. @comment() @text() ,
, attribute
. , @node()
attribute, @*.
XPath, :
, , * prefix:*. (
,
.)
, : comment(),
text(), processinginstruction() node().
, :
processinginstruction('pitarget').
484
6.
XPath (. 5)
, . , [speaker='
'], [@ > 100], [*] [1].
.
,
, .
, :
match <xsl:template>
<xsl:key>, .
,
,
.
, <xsl:number>.
, match
<xsl:template> <xsl:key>,
key().
current() (
7). ,
. , match <xsl:key>
, , ;
.
:
.
,
position() last();
. , [1], [position()!=1] [last()1]
, [@=''] [*] .
, ,
.
,
[@=''] ,
'', ,
, ,
''.
, .
. ,
[1] [last()1], [position()=1]
[position()=last()1].
, position() last().
(StepPattern)
485
attribute,
.
, child.
, :
last()
, ( ). ,
<> [last()=1],
last() <>,
<>.
<>,
<> .
position()
,
1. [1], [posi
tion()=1], <>,
<>
.
,
, .
, ,
<> . :
<xsl:applytemplates select="//">
<xsl:sort/>
<xsl:applytemplates>
, :
<xsl:template match="[1]">
. . .
</xsl:template>
<xsl:template match="">
. . .
</xsl:template>
<
>, <>
. <>
<> ,
. <
>, ,
:
<xsl:template match="">
<xsl:choose>
<xsl:when test="position()=1">
. . .
486
6.
</xsl:when>
<xsl:otherwise>
. . .
</xsl:otherwise>
</xsl:template>
,
,
, .
,
position() last() , ,
, . ,
speech[speaker=''][1] <speech>
,
<speaker> ''.
position() last()
, //. , //
[1] <>,
<> <> .
,
<> <>,
(//)[1] . ( ?
,
.)
. ,
[last()1]
. XSLT
[position()=last()1] ,
,
.
, .
XSLT ,
,
.
child::
<>.
child::.
attribute::
<>.
attribute::.
ChildAttribute (ChildOrAttributeAxisSpecifier)
*[@]
487
,
.
text()[startswith(.,'The')] ,
The.
p[@code][position() < 10] <p>
<p> , code.
p[position() < 10][@code] <p>
<p> , code.
*[not(@code =
,
precedingsibling::*/@code)] code,
code
.
comment()
@comment()
,
attribute .
attribute
,
, ,
.
ChildAttribute
(ChildOrAttributeAxisSpecifier)
XPath. :
child attribute.
.
ChildAttribute
|
( child | attribute ) ::
, 5, @,
attribute, , child.
,
ChildAttribute . ,
(,
, text()) child.
488
6.
, node()
, ,
,
.
. . 482.
, : child
attribute.
.
, . ,
[precedingsibling::*[1][self::]]
<>,
<>.
child::
child.
( .)
child, child:: .
attribute:: attribute.
@
attribute::.
,
ChildAttribute, . 482.
ID (IdKeyPattern)
(
) , ID
.
XPath, 5.
, , ,
id() key(), ,
.
id() key() 7.
489
ID (IdKeyPattern)
ID
id ( ) |
key ( , )
,
CSS
. :
,
, ,
,
,
.
. , ,
, , , .
,
ID, .
,
,
, ,
.
id() key()
, ID ,
.
, <> ISBN,
, :
:
<xsl:template match="[isbn='1861002688']">
:
<xsl:key name="isbnkey" match="" use="isbn"/>
<xsl:template match="key('isbnkey', '1861002688')>
, ,
XSLT.
490
6.
id('1')
ID,
'1'. ID,
DTD ID ( ).
key('empnr', '517541')
'517541'
empnr.
,
.
: key()
, key(),
, .
, .xml, :
<>
< ="1"> </>
< ="2"> </>
< ="3"> </>
< ="4"> ; </>
< ="5"> </>
< ="6"> </>
< ="7"> ; </>
< ="8"> </>
< ="9"> </>
</>
, .xsl,
:
<?xml version="1.0" encoding="iso88591"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="">
<xsl:template match="/">
<html>
<head>
<title> </title>
</head>
<body><center>
<xsl:applytemplates select="//"/>
</center></body>
ID (IdKeyPattern)
491
</html>
</xsl:template>
<xsl:template match="">
<h3> <xsl:valueof select="@"/></h3>
<p><xsl:applytemplates/></p>
</xsl:template>
</xsl:stylesheet>
, ,
.xsl, :
<?xml version="1.0" encoding="iso88591"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href=".xsl"/>
<xsl:key name="" match="" use="@"/>
<xsl:template match="key('','5')//text()">
<font color="red"><xsl:valueof select="."/></font>
</xsl:template>
</xsl:stylesheet>
:
<html>
<head>
<META httpequiv="ContentType"
content="text/html; charset=utf8">
<title> </title>
</head>
<body>
<center>
<h3> 1</h3>
<p> </p>
<h3> 2</h3>
<p> </p>
<h3> 3</h3>
<p> </p>
<h3> 4</h3>
<p> ; </p>
<h3> 5</h3>
<p><font
color="red"> </font></p>
<h3> 6</h3>
<p> </p>
<h3> 7</h3>
<p> ; </p>
492
6.
<h3> 8</h3>
<p> </p>
<h3> 9</h3>
<p> </p>
</center>
</body>
</html>
, , .
, [@=5]
.
, .
, ,
,
<xsl:choose>.
,
XSLT
,
<xsl:key> <xsl:number>.
,
XPath, 5, ,
; , ,
.
,
XPath .
XPath
XSLT, .
, ,
XSLT XPath,
, ,
, , ,
.
XPath,
XSLT.
XSLT, , ;
XPath XSLT ,
XPath ( ).
.
XPath 5. ,
, :
,
/.
XPath, ,
(,
).
count(..) ,
. .. XPath,
.
, , .
494
7.
,
. XPath
, ,
XSLT, . ,
XPath XSLT.
, boolean()
formatnumber()
number()
string()
ceiling()
floor()
round()
count()
sum()
generateid()
lang()
localname()
name()
namespaceuri()
unparsedentityuri()
false()
true()
not()
current()
last()
position()
document()
key()
id()
concat()
contains()
normalizespace()
startswith()
stringlength()
substring()
substringbefore()
substringafter()
translate()
495
boolean
elementavailable()
functionavailable()
systemproperty()
,
.
,
,
, ,
.
boolean
boolean() .
, boolean(1) .
XPath, 4.3
boolean()
,
.
; .
.
:
;
.
;
.
496
7.
;
. ,
, ,
.
, ,
boolean()
.
,
<header>, <footer>,
<footer> <header>.
<xsl:if test="boolean(//header) != boolean(//footer)">
<xsl:message>
, </xsl:message>
</xsl:if>
//header (,
<header>) //footer (,
<footer>)
, ,
.
, .
,
, ,
. XSLT ,
//footnote ,
,
, .
<xsl:variable name="" select="boolean(//footnote)"/>
.
true() . 613
false() . 528
497
ceiling
ceiling
ceiling() ,
.
, ceiling(33.9) 34.
XPath, 4.4
ceiling()
. ,
,
,
number().
:
.
,
. number()
. 580. ,
, .
, .
.
XPath ,
, NaN (),
2.
,
,
.
.
1.0, ,
.
498
7.
:
ceiling(1.0) = 1.0
ceiling(1.6) = 2.0
ceiling(17 div 3) = 6.0
ceiling(3.0) = 3.0
ceiling(8.2) = 8.0
ceiling('xxx') = NaN
ceiling(0.5) = 0
.
$ns ,
:
ceiling(count($ns) div 3).
.
floor() . 529
round() . 586
concat
concat() .
, .
, concat('', ' ', '')
.
XPath, 4.2
concat(1, 2, 3, )
,
( ).
1
n
. ,
,
,
string().
concat
499
;
.
,
string(),
.
concat()
<xsl:valueof>
. :
<xsl:valueof select="concat(, ' ', )"/>
:
<xsl:valueof select=""/>
<xsl:text> </xsl:text>
<xsl:valueof select=""/>
, concat() ,
(. <xsl:key> 4, key() . 548).
XSLT ,
, . :
<xsl:key name="" match=""
use="concat(, ' ', )"/>
(
) , :
<xsl:foreach select="key('', ' ')"/>
concat() :
, . XSLT
,
,
, .
, , , ,
,
normalizespace(),
substringbefore() substringafter().
500
7.
: ,
,
<> ( )
, .
, .xml:
<>
<
<
<
<
<
<
<
<
<
</>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
.xsl <>
concat()
, .
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:output indent="yes"/>
<xsl:template match="/">
<>
<xsl:foreach select="//">
<><xsl:valueof select="concat(@, ', ', @)"/></>
</xsl:foreach>
</>
</xsl:template>
</xsl:transform>
501
contains
<>, </>
<>, </>
<>, </>
<>, </>
</>
.
contains()
substring() . 595
contains
contains() .
, contains('Santorini', 'ant') .
XPath, 4.2
contains(, )
, .
, ,
, string().
. ,
,
,
string().
: , ,
.
,
,
502
7.
Unicode,
.
.
( ) ,
, , .
contains() ,
. , :
<xsl:if test="contains($name, 'Michael') and contains($name, 'Kay')"/>
, $name
Michael Kay Kay, Michael, Michael H. Kay, Michael
mas Kayaks, Inc..
, Unicode
,
, .
.
substring() . 595
substringafter() . 599
substringbefore() . 601
count
count() ;
.
, count(.) 1.
XPath, 4.1
count()
503
count
.
, .
, .
count()
.
, . ,
, .
, , ,
( ,
).
|, ,
, . ,
, , count( . | / )
1 , .
XPath ,
,
. , , ,
$, :
<xsl:if test="count($ | .) = count($)">
. . .
</xsl:if>
count() ,
, :
<xsl:if test="count([='']) != 0">
. . .
</xsl:if>
:
<xsl:if test="[='']"> . . . </xsl:if>
, <>
<>, .
, XSLT
504
7.
.
, .
count()
<xsl:number>. , <>,
count(precedingsibling::)+1
, <xsl:number/> .
count() ,
. <xsl:number>
,
; .
count(),
last().
<xsl:applytemplates> <xsl:foreach>;
last().
, :
<xsl:foreach select="[='']">
<h2> <xsl:valueof select="position()"/>
<xsl:valueof
select="count(../[=''])"/>
</h2>
. . .
</xsl:foreach>
XSLT
../[=''] .
:
<xsl:foreach select="[='']">
<h2> <xsl:valueof select="position()"/>
<xsl:valueof select="last()"/>
</h2>
. . .
</xsl:foreach>
,
.
<footnote>
:
<xsl:valueof select="count(//footnote)"/>
:
<xsl:variable name="numatts" select="count(@*)"/>
505
current
:
<>.
.xml:
<>
<
<
<
<
<
<
<
<
<
</>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
.xsl. ,
, 3.
,
<>,
. .
<
xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:valueof
select="count(//[not(@=preceding::/@)])"/>
</>
current
current() ,
, .
XSLT, 12.4
506
7.
current()
, , .
.
:
.
<xsl:applytemplates>
.
,
, .
<xsl:applytemplates> ,
.
,
,
.
<xsl:foreach>
, .
<xsl:foreach>
.
<xsl:calltemplate> <xsl:applyimports>
.
(
) .
, XPath ..
XPath current() .
.
, , .
current() . ,
, ,
, .
507
current
current() ,
,
, .
. ( , self::
node()).
current()
,
. ,
, <>
, , "" "",
,
. , ,
.
: current()
;
.
, .xml:
<>
< ="">
<>, </>
<></>
</>
< ="">
<> </>
<> </>
</>
< ="">
<> </>
<>. </>
</>
< ="">
<> </>
<> </>
<> </>
<> </>
<> </>
</>
</>
508
7.
.xsl.
<xsl:foreach>,
. ,
. [./@ =
current()/@], ,
. ,
, , .
, generateid()
, .
, ,
count(.|current())=2,
, ,
, .
.!=current(), ,
, ,
.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="/">
<html><body>
<xsl:variable name="" select="//"/>
<xsl:foreach select="$">
<h1><xsl:valueof select=""/></h1>
<p><i> </i><xsl:valueof select=""/>
<xsl:if test="count()!=1"> </xsl:if>
</p>
<xsl:variable name=""
select="$[./@=current()/@ and
generateid(.)!=generateid(current())]"/>
<xsl:if test="$">
<p> :</p><ul>
<xsl:foreach select="$">
<li><xsl:valueof select=""/></li>
</xsl:foreach>
</ul>
</xsl:if>
</xsl:foreach>
</body></html>
</xsl:template>
</xsl:transform>
<html>
<body>
document
509
<h1>, </h1>
<p><i> </i>
</p>
<h1> </h1>
<p><i> </i>
</p>
<p> :</p>
<ul>
<li> </li>
</ul>
<h1> </h1>
<p><i> </i>.
</p>
<p> :</p>
<ul>
<li> </li>
</ul>
<h1> </h1>
<p><i> </i>
</p>
</body>
</html>
.
5
document
document() XML
URI, XML
, .
, ,
URI.
, document('data.xml') da
ta.xml , , ,
.
XSLT, 12.1
document(uri)
document(uri, uri)
510
7.
uri
uri
(
)
,
. URI
URI,
.
:
(a) ,
URI,
(b) ,
, URI.
, ,
.
, document() XML,
URI. XML ,
. , ,
, ,
<xsl:stripspace> <xsl:preservespace>.
,
. document() ,
.
URI URL, ,
.
URI
XSLT URI: Uniform Reso
urce Identifier ( ).
URI URL
(Uniform Resource Locators, ),
. URI
URL,
( , , www.ibm.com
www.cam.ac.uk, ). URI
,
, ISBN .
,
document
511
URL. ,
URI URL ,
, , . , , ,
.
XSLT ,
URI, .
, XSLT
URL. ,
( TrAX API,
F)
URI.
URI, , ,
,
.
URI, document(),
XML. URI ,
XML, XSLT
(
): .
,
XML,
.
URI , .
URI data.xml.
( ,
URI)
URI. URI XML
URI ( XML
), ; document()
. ,
URI data.xml, XSLT
, ,
,
. document()
, , ,
URI.
URI ,
XSLT, 2,
URI. ( URI
, .) URI
URI XML
, . , ,
DOM,
URI, DOM.
.
512
7.
Microsoft, (MSXML3)
DOM, URI,
.
XSLT 1.1
URI xml:base.
W3C, XML Base;
, <base> HTML.
xml:base, URI,
URI
, xml:base.
URI, xml:base, URI,
URI
( URI, ,
xml:base).
XSLT 1.1 , URI
document(), ,
. , URI
URI <xsl:variable> ( <xsl:param>, <xsl:withparam>),
. ,
xml:base, URI ,
.
document()
URI ( URI ),
. ,
, generateid(),
, count(),
. , count(do
cument("a.xml") | document("a.xml")) (1).
. , URL http://
www.wrox.com/booklist#april2001
april2001. ,
URI
; , , XPointer,
.
.
( MIME
) .
(
). ,
, ,
, ;
. ( Saxon
, ID
).
document
513
document()
.
document()
,
, document(@href).
(, document(@href))
, ,
, href.
,
document() N
. document() :
N , N.
, ,
document (, 2) . 521.
:
URI . URI
, URI .
URI ,
. 510. ,
URI.
,
, data.xml,
data.xml , .
,
document(@href),
, ,
, URI
href . URI
URI , .
,
, ; :
<xsl:variable name="">.xml</xsl:variable>
<xsl:foreach select="document($)">
. . .
</xsl:foreach>
URI .xml
URI <xsl:variable>.
document() ,
, ,
514
7.
href. ,
:
<>
< ="28121999" ="New York Times"
="/NYT/28121999/3.xml"/>
< ="06012000" ="Washington Post"
="/WPost/06012000/12.xml"/>
</>
, document(). , :
<xsl:template match="">
<xsl:foreach select="">
<h2> <xsl:valueof select="@"/></h2>
<xsl:applytemplates select="document(@)"/>
</xsl:foreach>
</xsl:template>
@ ,
, URI
URI <>,
URI . ,
<> XML
xml:base .
,
, .
.
, , ,
. :
:
.
:
. <xsl:applytempla
tes> :
<xsl:applytemplates select="document(@)" mode=""/>
,
.
<xsl:applytemplates> <xsl:template> 4.
,
,
<xsl:include>.
document
515
: document()
XML,
.
. :
.
document()
, <xsl:include> <xsl:import>.
.
,
<xsl:include> <xsl:import>.
dummy.xsl,
.
.xsl document()
,
href <xsl:include> <xsl:import>.
, . ,
HTML.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="/">
<html><body>
<h1> </h1>
<ul>
<xsl:applytemplates select="*/xsl:include | */xsl:import"/>
</ul>
</body></html>
</xsl:template>
<xsl:template match="xsl:include | xsl:import">
<li><xsl:choose>
<xsl:when test="localname()='import'">
<xsl:valueof select="concat(' ', @href)"/>
</xsl:when>
<xsl:otherwise>
<xsl:valueof select="concat(' ', @href)"/>
</xsl:otherwise>
</xsl:choose>
516
7.
<xsl:variable name="" select="document(@href)"/>
<ul>
<xsl:applytemplates
select="$/*/xsl:include | $/*/xsl:import"/>
</ul>
</li>
</xsl:template>
</xsl:transform>
dummy.xsl:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:include href="dummya.xsl"/>
</xsl:transform>
dummya.xsl :
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:import href="dummyb.xsl"/>
<xsl:import href="dummyc.xsl"/>
</xsl:transform>
dummyb.xsl dummyc.xsl
:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
</xsl:transform>
dummy.xsl (. 7.1):
. 7.1. dummy.xsl
document
517
document(1, 2)
, ,
URI
URI 2. ,
1 URL ( data.xml),
data.xml , XML,
2.
2 . ,
document(@href, / )
URI, ,
href, URI.
:
document() N
1. document()
: N 2. ,
, ,
document (, 2) . 521.
2 . XSLT
.
, , , ,
.
URI ,
, , :
document(@href, document(''))
,
, URI
, href.
document()
,
. URL,
, document('.xml').
document(''),
.
,
string(),
518
7.
URL, .
URI. URI,
URI
, .
URI ,
, <xsl:include> <xsl:import>
XML, (
XSLT 1.1) URI
xml:base.
, , URL
, URL HTML: document('
.xml') ,
.xml , .
,
, URI. XSLT ,
document('') .
, , , URI
, document(),
. URI , ,
,
, ( XSLT 1.1), xml:base,
, document(''),
. ,
, .
,
<xsl:include> <xsl:import>,
, .
document
519
)
XSLT 1.0,
, ,
. XSLT 1.0,
XSLT 1.1.
XSLT
, ,
.
:
.xml :
<>
< ="">
<>, </>
<></>
</>
< ="">
<> </>
<> </>
</>
< ="">
<> </>
<>. </>
</>
< ="">
<> </>
<> </>
<> </>
<> </>
<> </>
</>
</>
.xsl.
<>
<:>,
<>.
current() .
., .
, <:>.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:=".uri"
520
7.
excluderesultprefixes=""
>
<xsl:template match="/">
<html><body>
<xsl:foreach select="//">
<h1><xsl:valueof select=""/></h1>
<p>: <xsl:valueof
select="document('')/*/:
[@=current()/@]/@"/>
</p>
</xsl:foreach>
</body></html>
</xsl:template>
<: ="" =""/>
<: ="" =""/>
<: ="" =" "/>
</xsl:transform>
<html>
<body>
<h1>, </h1>
<p>: </p>
<h1> </h1>
<p>: </p>
<h1> </h1>
<p>: </p>
<h1> </h1>
<p>: </p>
</body>
</html>
XSLT 1.1
XSLT 1.1. 1_1.xsl.
.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1"
xmlns:book=".uri"
excluderesultprefixes=""
>
<xsl:template match="/">
<html><body>
<xsl:foreach select="//">
<h1><xsl:valueof select=""/></h1>
<p>: <xsl:valueof
document
521
select="$/
[@=current()/@]/@"/>
</p>
</xsl:foreach>
</body></html>
</xsl:template>
<xsl:variable name="">
< ="" =""/>
< ="" =""/>
< ="" =" "/>
</xsl:variable>
</xsl:transform>
document(, 2)
,
. ( XSLT 1.0
.)
,
string().
,
.
, , ,
: ,
( ). XSLT
.
URI.
, URI
2.
, ,
. XSLT 1.1
URI xml:base.
:
key() id() ,
.
:
<!>
<xsl:valueof select="document('a.xml')/key('k1', 'val1')"/>
<!>
522
7.
<xsl:for
each>:
<xsl:foreach select="document('a.xml')">
<xsl:valueof select="key('k1', 'val1')"/>
</xsl:foreach>
.
id() . 545
key() . 548
elementavailable
,
XSLT .
, elementavailable('xsl:text')
.
XSLT, 15
elementavailable()
, .
,
,
string().
.
: ,
, .
, XML
,
,
elementavailable().
523
element5available
XSLT
http://www.w3.org/1999/XSL/Transform, ,
XSLT ,
. XSLT 1.0 :
<xsl:applyimports>
<xsl:applytemplates>
<xsl:attribute>
<xsl:calltemplate>
<xsl:choose>
<xsl:comment>
<xsl:copy>
<xsl:copyof>
<xsl:element>
<xsl:fallback>
<xsl:foreach>
<xsl:if>
<xsl:message>
<xsl:number>
<xsl:processinginstruction>
<xsl:text>
<xsl:valueof>
<xsl:variable>
XSLT 1.1
, <xsl:document>.
XSLT,
. XSLT ,
<xsl:template> <xsl:key>, ,
( ,
: , Microsoft
MSXML3, , XSLT).
<xsl:param>, <xsl:withparam>, <xsl:sort>,
<xsl:when> <xsl:otherwise>,
, .
,
XSLT 1.1, elementavailab
le('xsl:document'). ,
: , ,
XSLT 1.0
.
:
:
,
.
,
.
Saxon, ,
XSLT 1.1.
.xml. :
<>
524
7.
<> </>
<>1912</>
<>Song</>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
<>
<>My heart all Winter lay so numb,</>
<>The earth so dead and frore,</>
. . .
.xsl.
<xsl:choose>, element
available()
.
, saxon
, <saxon:output> .
<xsl:stylesheet> version="1.1",
XSLT 1.0 <xsl:document>
.
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:template match="">
<>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:applytemplates select=""/>
</>
</xsl:template>
<xsl:template match="">
<xsl:variable name=""
select="concat('', position(), '.xml')"/>
< ="{position()}" href="{$}"/>
<xsl:choose>
<xsl:when test="elementavailable('xsl:document')">
<xsl:document href="{$}">
<xsl:copyof select="."/>
</xsl:document>
</xsl:when>
<xsl:when test="elementavailable('saxon:output')"
xmlns:saxon="http://icl.com/saxon">
element5available
525
<saxon:output file="{$file}"
xsl:extensionelementprefixes="saxon">
<xsl:copyof select="."/>
</saxon:output>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
.
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XSLT,
,
( ):
<?xml version="1.0" encoding="utf8" ?>
<>
<>Song</>
<>Rupert Brooke</>
<>1912</>
< ="1" href="1.xml"/>
< ="2" href="2.xml"/>
< ="3" href="3.xml"/>
</>
, 1.xml, 2.xml
3.xml, . 1.xml:
<?xml version="1.0" encoding="utf8" ?>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
elementavailable()
XSLT 1.1 <xsl:script>,
, XSLT 1.1 ,
, XSLT 1.0.
XSLT 1.0, version="1.0"
<xsl:stylesheet> , versi
on="1.1", <xsl:script> ,
.
,
526
7.
, , ,
XSLT 1.0, XSLT 1.1.
, XSLT,
, :
.
, elementavailable()
,
[xsl:]extensionelementprefixes.
XSLT ,
,
.
,
. , .
, :
.
URI,
. :
XSLT
URI.
,
XSLT,
,
.
XSLT
, XSLT,
XSLT 1.0, , 1.1
. , ,
. ,
XSLT 1.1 , <xsl:document>. (,
<xsl:script> ,
.)
<xsl:document>, XSLT,
XSLT.
, <xsl:if>
, <xsl:fallback>,
.
element5available
527
elementavailable() XSLT
1.0? , . ,
,
2.0, elementavailable(),
,
1.0 1.1.
, 1.0 1.1 ele
mentavailable().
. XSLT,
, HTML.
,
, , ,
, .
1.0,
,
XSLT 1.0; ,
elementavailable(). ,
,
.
, ,
XSLT 2.0.
XSLT 1.0, version="2.0" <xsl:styles
heet> xsl:version="2.0"
, <xsl:if> element
available(), .
version="1.0",
XSLT 2.0 , .
. ,
,
elementavailable(),
, ,
<xsl:if> <xsl:fallback>.
, Saxon ,
. ,
disableoutputescaping.
, , :
<xsl:choose xmlns:saxon="http://icl.com/saxon">
<xsl:when test="elementavailable('saxon:entityref')">
<saxon:entityref name="nbsp"
xsl:extensionelementprefixes="saxon"/>
</xsl:when>
<xsl:otherwise>
528
7.
<xsl:text disableoutputescaping="yes">&nbsp;</xsl:text>
</xsl:otherwise>
</xsl:choose>
elementavailable()
<xsl:fallback>, 4:
<xsl:fallback> , ,
, , . , ,
, <xsl:fallback>
,
. ,
<xsl:copyof>.
,
.
<xsl:breakpoint>,
XSLT 37.1.
, .
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="38.0">
<xsl:template name="">
<xsl:if test="elementavailable('xsl:breakpoint')">
<xsl:breakpoint/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
, version <xsl:stylesheet>
"1.0", . version
,
, <xsl:breakpoint>
,
. ( XSLT 1.1
, 1.0 1.1.)
3.
.
functionavailable() . 535
<xsl:fallback> 4
false
.
floor
529
XPath, 4.3
false()
XPath ,
true() false().
.
.
<xsl:if test="false()">
. XML
, .
,
:
<xsl:calltemplate name="">
<xsl:withparam name="" select="false()"/>
</xsl:calltemplate>
.
true() . 613
floor
floor() ,
.
, floor(11.3) 11.
XPath, 4.4
530
7.
floor()
. ,
,
, number().
:
.
, , , .
num
ber() . 580. ,
, , .
, .
.
,
,
.
. ,
, 2.
:
floor(1.0) = 1.0
floor(1.6) = 1.0
floor(17 div 3) = 5.0
floor(3.0) = 3.0
floor(8.2) = 9.0
.
ceiling() . 497
round() . 586
531
format5number
formatnumber
formatnumber()
.
, .
<xsl:decimalformat>.
, formatnumber(12.5, '$#.00') $12.50.
XSLT, 12.3
Java JDK 1.1;
.
formatnumber(, )
formatnumber(, , )
. ,
,
, number().
. ,
, ,
string().
(
)
() ,
<xsl:decimalformat>.
.
.
( )
, ,
, .
, , ;
XML ,
532
7.
,
formatnumber().
<xsl:decimalformat> ,
URI, .
,
.
<xsl:decimalformat> .
, .
XSLT
Java JDK 1.1.
, 5 :
pattern
subpattern
prefix
suffix
integer
fraction
zerodigit* digit*
patternseparator
; ( )
decimalpoint
. ( )
groupingseparator
, ( )
digit
# ( )
zerodigit
0 ( )
specialCharacters
;, ., ,, # 0
patternseparator, decimalpoint, groupingseparator, digit ze
rodigit. <xsl:decimalformat>
.
(subpattern) .
()
.
:
zerodigit ( 0)
533
format5number
digit ( #)
,
.
decimalpoint ( .)
groupingseparator ( ,) .
patternseparator ( ;)
.
minussign ( )
percentsign ( %)
100
.
permille ( )
1000
.
apostrophe (')
,
.
9 #9,
'#'0.
. 0.00
0.00;0.00.
,
; ,
, .
#,##0.0#;(#) , #,##0.0#;(#,##0.0#).
XSLT
JDK 1.1.
JDK 1.1:
( #xA4) E,
,
. , XSLT
, ,
. ,
Java, ,
Java.
, ,
,
.
,
.
. #,##,###,####
.
534
7.
. ,
, .
,
<xsl:number>.
, .
formatnumber() ,
. <xsl:number>
.
.
formatnum
ber() .
<xsl:decimalformat>
4.
1234.5
#,##0.00
1,234.50
123.456
#,##0.00
123.46
1000000
#,##0.00
1,000,000.00
59
#,##0.00
59.00
1 div 0
#,##0.00
Infinity
1234
###0.0###
1234.0
1234.5
###0.0###
1234.5
.00035
###0.0###
0.0004
0.25
#00%
25%
0.736
#00%
74%
#00%
100%
42
#00%
4200%
3.12
#.00;(#.00)
(3.12)
3.12
#.00;#.00CR
3.12CR
.
<xsl:decimalformat> 4
535
function5available
functionavailable
.
,
.
, functionavailable('concat')
.
XSLT, 15
functionavailable()
, .
, ,
,
string(). .
: , ,
.
, XML
,
,
functionavailable().
URI ,
.
, XPath XSLT (
);
,
, . , XSLT,
XSLT 1.0,
( , ):
boolean
ceiling
generateid
id
round
startswith
536
concat
contains
count
current
document
elementavailable
false
floor
formatnumber
functionavailable
7.
key
lang
last
localname
name
namespaceuri
normalizespace
not
number
position
string
stringlength
substring
substringafter
substringbefore
sum
systemproperty
translate
true
unparsedentityuri
XSLT 1.1
. , XSLT 2.0 distinct().
XSLT
:
<xsl:if test="functionavailable('distinct')">
,
,
. , functionavailable()
, ,
, ,
.
,
: ,
.
functionavailable()
,
, , 1.0,
,
.
1.0
. ,
.
, 1.1 XSLT,
XSLT.
, <xsl:if>
.
version <xsl:stylesheet>
, "1.0" ( "1.1"
XSLT 1.1), XSLT
function5available
537
, ,
.
, 2.0 XSLT
schemadatatype(), ,
. , ,
:
<xsl:if test="functionavailable('schemadatatype')>
.
, ,
, , , use
. ,
, <xsl:if> functionavailable().
,
functionavailable()
,
. ,
, functionavailable()
, <xsl:if> ,
.
XSLT 1.1
(, <xsl:variable>)
, .
XSLT 1.0,
, .
,
( , xt:nodeset()
msxml:nodeset()). ,
, , ,
.
538
7.
,
,
<xsl:applytemplates>
. XSLT 1.1
<xsl:applytemplates>;
, node
set() , .
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:template name=""
xmlns:msxml="urn:schemasmicrosoftcom:xslt"
xmlns:xt="http://www.jclark.com/xt"
xmlns:saxon=" http://icl.com/saxon">
<xsl:param name=""/>
<xsl:choose>
<xsl:when test="systemproperty('xsl:version') > 1.0">
<xsl:applytemplates mode=""
select="$"/>
</xsl:when>
<xsl:when test="functionavailable('msxml:nodeset')">
<xsl:applytemplates mode=""
select="msxml:nodeset($)"/>
</xsl:when>
<xsl:when test="functionavailable('xt:nodeset')">
<xsl:applytemplates mode=""
select="xt:nodeset($)"/>
</xsl:when>
<xsl:when test="functionavailable('saxon:nodeset')">
<xsl:applytemplates mode=""
select="saxon:nodeset($)"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
:
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="$"/>
</xsl:calltemplate>
</xsl:variable>
539
generate5id
.
elementavailable() . 522
generateid
generateid() XML,
. ,
.
, generateid(..)
N015732, b23a1c79.
XSLT, 12.4
generateid()
generateid()
(
)
(
).
,
.
, .
ASCII, .
,
XML.
,
.
,
( ).
,
.
540
7.
.
,
. ,
.
.
,
( ) .
generateid().
.
generateid()
generateid()
. , ID IDREF
, <a name="X"> <a href="#X"> HTML
.
: generateid()
.xml,
. .
<>
<>
<></>
<> </>
<>
<> </>
<>5</>
<> . . . </>
</>
<>
<> </>
<>2</>
<> . . . </>
</>
</>
<>
<></>
<> </>
<>
<> </>
<>5</>
<> . . . </>
generate5id
541
</>
<>
<> </>
<>2</>
<> . . . </>
</>
</>
</>
.xsl HTML,
,
.
.
generateid() <>.
,
, 3:
<html
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsl:version="1.0"
>
<body>
<h1></h1>
<xsl:foreach select="//">
<xsl:sort select=""
order="descending" datatype="number"/>
<h2><xsl:valueof select=""/></h2>
<p>: <xsl:valueof select=""/></p>
<p>: <xsl:valueof select=""/></p>
<p>: <a href="#{generateid(parent::)}">
<xsl:valueof select="parent::/"/></a></p>
</xsl:foreach>
<h1></h1>
<xsl:foreach select="//">
<h2><a name="{generateid()}">
<xsl:valueof select=""/>
</a></h2>
<p><xsl:valueof select=""/></p>
</xsl:foreach>
</body>
</html>
, generateid()
.
Saxon.
, .
542
7.
<a>,
.
<html>
<body>
<h1></h1>
<h2> </h2>
<p>: . . . </p>
<p>: 5</p>
<p>: <a href="#b2b1b2"></a></p>
<h2> </h2>
<p>: . . . </p>
<p>: 5</p>
<p>: <a href="#b2b1b4"></a></p>
<h2> </h2>
<p>: . . . </p>
<p>: 2</p>
<p>: <a href="#b2b1b2"></a></p>
<h2> </h2>
<p>: . . . </p>
<p>: 2</p>
<p>: <a href="#b2b1b4"></a></p>
<h1></h1>
<h2><a name="b2ab1"></a></h2>
<p> </p>
<h2><a name="b2b1b4"></a></h2>
<p> </p>
</body>
</html>
, generateid(), :
,
, , :
//node()[generateid()=$X]
,
:
<xsl:key name="gidkey" match="*" use="generateid()"/>
:
key('gidkey', $X)
,
ID ,
id().
, ID, ,
. ,
generate5id
543
ID . ,
,
ID .
generateid()
generateid()
. , $X $Y ,
,
generateid($x) = generateid($Y)
, $X $Y
.
, $X = $Y ,
,
.
, :
. , XML
:
<>
<></>
<> </>
<> </>
<></>
<> </>
<> </>
<> </>
<></>
<> </>
<> </>
<> </task>
</>
HTML
:
<h2> </h2>
<ol>
<li> </li>
<li> </li>
</ol>
<h2> </h2>
<ol>
<li> </li>
<li> </li>
<li> </li>
</ol>
544
7.
<h2> </h2>
<ol>
<li> </li>
<li> </li>
<li> </li>
</ol>
, XML
.
XML,
, .
, ,
. , .
:
<xsl:foreach select="">
<h2> <xsl:valueof select="."/></h2>
<ol>
. . .
</ol>
</xsl:foreach>
?
<>,
<> <>.
generateid():
<xsl:foreach select="">
<h2> <xsl:valueof select="."/></h2>
<ol>
<xsl:variable name="id" select="generateid()"/>
<xsl:foreach select="followingsibling::[
generateid(precedingsibling::[1])
= $id]">
<li><xsl:valueof select="."/></li>
</xsl:foreach>
</ol>
</xsl:foreach>
XPath
generateid() |.
,
,
. : , $x $y
,
:
<xsl:if test="generateid($x) = generateid($y)">
:
<xsl:if test="count($x | $y ) = 1">
545
id
.
, (Jeni
Tennison), ,
, ,
. generateid(),
. ,
, $x $y
.
.
id() . 545
key() . 548
id
id() ,
ID.
, ID, id('A321
780') ,
< ="A321780">.
XPath, 4.1
id()
ID,
.
, ID.
,
, string(),
, .
546
7.
ID: ,
, ID,
,
.
,
: (
), ,
,
ID. ,
string(),
, .
ID , DTD
ID.
IDREF
IDREFS,
. ,
IDREF IDREFS .
ID
.
, .
, ID,
.
ID
( , DTD
). XSLT XPath ,
,
. ,
, ID,
.
ID.
(, ,
ID ).
.
XML, ,
DTD. , XSLT
, ID , id()
.
XML.
,
XML.
547
id
id()
ID.
;
id ID,
id('B1234')
:
//*[@id='B1234']
id()
, ,
, , ,
.
key() id().
id() key() ,
ID, , . key()
, .
, id() ,
.
<xsl:foreach> :
<xsl:foreach select="document('a.xml')">
<xsl:copyof select="id('B1234')"/>
</xsl:foreach>
IDREFS,
. ,
<> IDREFS,
, .
<> :
<xsl:template match="">
. . .
: <xsl:foreach select="id(@)">
<xsl:valueof select=""/>
<xsl:if test="position()!=last()">, </xsl:if>
<xsl:if test="position()=last()1"> </xsl:if>
</xsl:foreach>
</xsl:template>
.
key() . 548
548
7.
key
key()
.
<xsl:key>, 4.
, :
<xsl:key name="" match="" use="@"/>
key('', 'N498PAA') ,
, < ="N498PAA">.
XSLT, 12.2
key(, )
. ,
,
string().
, <xsl:key>.
,
(. ).
, .
: XML,
,
,
key().
, URI ;
.
<xsl:key>, ,
URI, .
<xsl:key> ,
: ,
.
549
key
,
,
string().
, , ,
.
,
.
,
. N
,
,
N.
string(),
.
,
,
; , ,
.
key()
( ). ,
, ,
,
key()
.
.
:
. , <>,
<> . . :
<xsl:foreach select="//[='. . ']">
,
:
<xsl:key name="" match="" use=""/>
. . .
<xsl:foreach select="key('', '. . ')"/>
key() .
<xsl:foreach>:
<xsl:foreach select="document('a.xml')">
550
7.
.
; ,
,
.
;
,
.
:
:
, (
document()) .
,
SQL.
.xml:
<>
< ="">
<> </>
<> </>
</>
< ="">
<> </>
<>. </>
</>
</>
, .xml,
. ,
, key()
, .
<>
< =". ">
<>1852</>
<>1956</>
<>
. , , ,
. .</>
</>
< =" ">
551
key
<>1881</>
<>1972</>
<> ( ) <i>
</i>, , .
1919,
, . . .
, , ,
.</>
</>
</>
.xsl ,
<> .
.xml, .
,
. docu
ment() ,
XLST , ,
,
.
<xsl:foreach>
,
key()
. ,
,
.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:key name="" match="" use="@"/>
<xsl:variable name="" select="document('.xml')"/>
<xsl:template match="/">
<html><body>
<xsl:variable name="" select="//"/>
<xsl:foreach select="$">
<! >
<h1><xsl:valueof select=""/></h1>
<h2><xsl:if test="count()!=1"></xsl:if></h2>
<xsl:foreach select="">
<! >
<xsl:variable name="" select="."/>
<h3><xsl:valueof select="$"/></h3>
<xsl:foreach select="$">
<! >
552
7.
<! , >
<xsl:variable name="" select="key('', $)"/>
<p><xsl:valueof
select="concat($/, ' ',
$/)"/></p>
<p><xsl:valueof select="$/"/></p>
</xsl:foreach>
</xsl:foreach>
</xsl:foreach>
</body></html>
</xsl:template>
</xsl:transform>
<html>
<body>
<h1> </h1>
<h2></h2>
<h3> </h3>
<p>1881 1972</p>
<p> ( ) ,
, .
1919, ,
. . . ,
, ,
.</p>
<h1> </h1>
<h2></h2>
<h3>. </h3>
<p>1852 1956</p>
<p>
. , , ,
. .</p>
</body>
</html>
, .
,
(Steve Muench) Oracle.
.
, , ,
, , , .
,
, , ,
, ,
553
key
.
.
,
. ,
, :
<xsl:key name="" match="" use="@"/>
.
, ,
. ,
, , ,
key() :
<xsl:foreach select="//[generateid() =
generateid(key('', @)[1])]">
generateid()
, key().
, ,
:
<xsl:foreach select="//[@ =
key('', @)[1]/@]">
,
.
, :
<xsl:foreach select=key('', @)">
:
.xml :
<>
<
<
<
<
<
<
<
<
<
</>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
554
7.
.xsl :
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:key name="" match="" use="@"/>
<xsl:template match="/">
<html><body>
<xsl:foreach select="//[generateid()
= generateid(key('', @)[1])]">
<h1><xsl:valueof select="@"/></h1>
<xsl:foreach select="key('', @)">
<xsl:valueof select="@"/><br/>
</xsl:foreach>
</xsl:foreach>
</body></html>
</xsl:template>
</xsl:transform>
(. 7.2):
. 7.2.
.
<xsl:key> 4
id() . 545
555
lang
lang
lang() ,
, xml:lang, ,
.
, <para lang="fr
CA"> ( ), lang('fr')
.
XPath, 4.3
lang()
.
,
, string().
,
.
xml:lang
, , xml:lang
, . xml:lang
, lang() .
xml:lang ,
XML (, ,
XML,
).
:
,
ISO 639. , en,
fr.
, .
XML
RFC 1766.
556
7.
,
:
. ,
enUS; frCA.
ISO 3166 ,
IANA (Internet Assigned Numbers Authority).
ISO 3166
; DE , CZ .
, ISO 3166
( ) GB, UK.
.
, ASCII (az,
AZ).
, IANA (. www.iana.org),
i. iNavajo.
, , x.
, xJava , Java.
xml:lang ,
. xml:lang
. ,
, xml:lang
xml:lang="en",
xml:lang="de".
XSLT lang() ,
. lang('en') ,
lang('jp') .
:
xml:lang
( ), .
of xml:lang
, , (
), .
.
,
.
xml:lang
XML, lang()
.
lang()
.
557
lang
: lang()
.xml ISO
().
XSLT 1.0.
<>
<iso>19991116</iso>
<iso>19991008</iso>
<iso>19990813</iso>
<iso>19990709</iso>
<iso>19990421</iso>
<iso>19981216</iso>
<iso>19980818</iso>
</>
.xsl ,
, .
,
.
. Saxon :
saxon .xml .xsl =fr
xt:
xt .xml .xsl =fr
: en, de fr.
<?xml version="1.0" encoding="utf8"?>
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:output encoding="utf8"/>
< xmlns=".uri">
< xml:lang="en">
<m>January</m><m>February</m><m>March</m><m>April</m>
<m>May</m><m>June</m><m>July</m><m>August</m>
<m>September</m><m>October</m><m>November</m><m>December</m>
</>
< xml:lang="fr">
<m>Janvier</m><m>Fvrier</m><m>Mars</m><m>Avril</m>
<m>Mai</m><m>Juin</m><m>Juillet</m><m>Aot</m>
<m>Septembre</m><m>Octobre</m><m>Novembre</m><m>Dcembre</m>
</>
558
7.
< xml:lang="de">
<m>Januar</m><m>Februar</m><m>Mrz</m><m>April</m>
<m>Mai</m><m>Juni</m><m>Juli</m><m>August</m>
<m>September</m><m>Oktober</m><m>November</m><m>Dezember</m>
</>
</>
<xsl:param name="" select="'en'"/>
<xsl:template match="iso">
< xmlns:=".uri" xsl:excluderesultprefixes="">
<xsl:valueof select="substring(., 7, 2)"/>
<xsl:text> </xsl:text>
<xsl:variable name="" select="number(substring(.,5,2))"/>
<xsl:valueof select="document('')/*/
:/:[lang($)]/:m[$]"/>
<xsl:text> </xsl:text>
<xsl:valueof select="substring(., 1, 4)"/>
</>
</xsl:template>
</xsl:transform>
(
document('')), .
(document('')),
(* <xsl:stylesheet>
<xsl:transform>), <> (
.uri, XPath
), <>,
, <m> .
[lang($)] <>,
.
,
, document() . 509.
XSLT 1.1
. <>
<xsl:variable name=""> (
), ,
, :
<xsl:valueof select="$/[lang($)]/m[$]"/>
XSLT 1.0 ,
/.
:
<?xml version="1.0" encoding="utf8" ?>
<>16 November 1999</>
559
last
<>08
<>13
<>09
<>21
<>16
<>18
October 1999</>
August 1999</>
July 1999</>
April 1999</>
December 1998</>
August 1998</>
:
<?xml version="1.0" encoding="utf8" ?>
<>16 Novembre 1999</>
<>08 Octobre 1999</>
<>13 Aot 1999</>
<>09 Juillet 1999</>
<>21 Avril 1999</>
<>16 Dcembre 1998</>
<>18 Aot 1998</>
:
<?xml version="1.0" encoding="utf8" ?>
<>16 November 1999</>
<>08 Oktober 1999</>
<>13 August 1999</>
<>09 Juli 1999</>
<>21 April 1999</>
<>16 Dezember 1998</>
<>18 August 1998</>
lang() ; ,
,
xml:lang.
ancestororself::*[@xml:lang][1]/@xml:lang.
last
last() .
. last()
, .
, <xsl:foreach>
( )
:
<xsl:if test="position()!=last()">, </xsl:if>
XPath, 4.1
560
7.
last()
, . ,
.
XPath last()
. XSLT :
.
( XPath,
)
. :
,
( use
<xsl:key>), ,
,
.
<xsl:applytemplates>
,
, <xsl:applytemplates>.
<xsl:foreach>
,
, <xsl:foreach>.
,
. 5
6 .
last(),
.
last()
<xsl:template> ( <xsl:foreach>),
, <xsl:apply
templates>. , <xsl:applytemplates>
561
last
, ,
.
,
. last() .
<xsl:applytemplates select="//"/>
. . .
<xsl:template match="">
<div align="center">
<img src="{@href}"/>
<p> <xsl:valueof select="position()"/>
<xsl:text/> <xsl:valueof select="last()"/></p>
</div>
</xsl:template>
, last()
<xsl:foreach>, ,
<xsl:foreach>.
, <xsl:foreach> ,
select .
last() ,
. :
:
position() last()
, , .
.xml.
, :
<>
< ="">
<> </>
<> </>
<> </>
<> </>
<> </>
</>
</>
.xsl ,
:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
562
7.
version="1.0"
>
<xsl:template match="">
<>
<xsl:foreach select="">
<xsl:valueof select="."/>
<xsl:choose>
<xsl:when test="position() = last()"/> <! >
<xsl:when test="position() = last()1"> </xsl:when>
<xsl:otherwise>, </xsl:otherwise>
</xsl:choose>
</xsl:foreach>
</>
</xsl:template>
</xsl:transform>
.xml:
<></>
<> </>
<>. </>
<> , , </>
<xsl:calltemplate> ,
last() ,
.
last() <xsl:sort>,
. ,
:
<xsl:sort select="position() mod (ceiling(last() div 3))"/>
A, B, C, D, E, F, G, H A, D, G, B, E, H,
C, F, ,
.
last() ,
, ,
, (
). ,
:
<>
< ="" ="" =""/>
< ="" ="" =""/>
< ="" ="" =""/>
< ="" ="" =""/>
< ="" ="" =""/>
< ="" ="" =""/>
563
last
< ="" ="" =""/>
< ="" ="" =""/>
</>
:
/[last()]
/[@=''][last()]
/[@=''][last()1]
/[@=''] [position() != last()]
last()
,
. :
<xsl:template name="p" match="p">
<xsl:copy>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[last()]">
<xsl:calltemplate name="p"/>
<hr/>
</xsl:template>
,
<p>, ,
,
<p>. <xsl:if>
:
<xsl:template match="p">
<xsl:copy>
<xsl:applytemplates/>
</xsl:copy>
<xsl:if test="position()=last()">
<hr/>
</xsl:if>
</xsl:template>
,
. <p> <xsl:applytemplates>
<xsl:sort>, .
, <hr/>
<p> , <hr/>
<p> .
564
7.
, , last() .
last()
:
<xsl:valueof select="para[last()]"/>
[position()=last()],
X position()=X.
, :
<xsl:if test="last()"/>
, last(),
, boolean().
, last() .
.
position() . 582
<xsl:number> 4
localname
localname() ,
, ,
.
, <>
localname() ; <ms:schema>
schema.
XPath, 4.1
localname()
localname()
(
)
, .
,
. ,
.
.
,
.
565
local5name
, ,
, URI . ,
<> <:> :
<xsl:applytemplates select="*[localname()='']"/>
, :
<xsl:template match="*[localname()='']">
XML.
,
<> <:> .
.
. ,
( )
,
( URI )
.
, ,
. ,
<:> <:>:
:
<xsl:template match=": | :">
566
7.
:
<xsl:template match="*[localname()='']">
HTML,
,
, :
<xsl:template match="*" mode="">
<table>
<xsl:foreach select="attribute::node()">
<xsl:sort select="namespaceuri()"/>
<xsl:sort select="localname()"/>
<tr>
<td><xsl:valueof select="namespaceuri()"/></td>
<td><xsl:valueof select="localname()"/></td>
<td><xsl:valueof select="."/></td>
</tr>
</xsl:foreach>
</table>
</xsl:template>
.
name()
namespaceuri() . 572
name
name() , .
, ,
XML.
, <ms:schema>,
name() ms:schema.
XPath, 4.1
name()
name()
567
name
( , .
)
,
.
, .
,
.
, .
. .
; .
, ,
XML,
, URI .
, ,
XML,
, URI .
; .
, ,
.
; .
;
. ( xmlns:.)
, name()
, localname().
, ,
, XML.
. ,
URI .
, , URI
,
.
568
7.
:
<xsl:variable name="">
< xmlns:cat="http://acme.com/catalog">
<xsl:copyof select="//cat:[@ < 1000"/>
</>
</xsl:variable>
name($//)?
<>
,
,
. ,
, cat URI
http://acme.com/catalog.
<>
( =""), .
<xsl:copyof> <>
,
<> .
, ,
URI http://acme.com/catalog.
( cat),
URI. , name() <>
. ,
cat:; .
name() , (
, ), ,
.
name
569
, ,
<> ISBN:
<xsl:if test="not(@ISBN)">
<xsl:message> <xsl:valueof select="name()"/>
ISBN</xsl:message>
</xsl:if>
name()
, , : doc:[name(..)='doc:'].
.
, ,
.
doc: ,
DOC doc
,
, .
, , .
doc:
[parent::doc:]. ,
, ,
. self :
, <>,
<xsl:if test="self::">.
, .
, ,
. , *[starts
with(name(),'private.')] ,
private.. ,
XML
.
,
private., private="yes".
, na
me() .
: ,
, URI
, , name().
, :
*[namespaceuri()='' and startswith(localname(),'private.')]
name()
, .
,
, .
, , ,
570
7.
. select <xsl:sort>
,
:
<xsl:sort select="*[name()=$]"/>
$ ,
, .
, , self:
. , self
. , ,
:
<xsl:copyof select="@*[not(self::)]"/>
, self::
<> self, ,
.
na
me()!=''. localname()!="'' and namespace
uri()=''".
name()
, , <xsl:element name=
"{name()}">. name()
, ,
.
<xsl:copy>. , <xsl:copy> : ,
.
localname() namespaceuri():
<xsl:element name="{localname()}" namespace="{namespaceuri()}">
HTML
, .
.
,
.
.
571
name
.xsl
, URI
, ,
, , URI .
.
name() (
).
<?xml version="1.0" encoding="utf8"?>
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="/">
<html><body>
<h1> </h1>
<table border="1" cellpadding="5">
<tr><td></td><td></td>
<td> </td><td>URI </td></tr>
<xsl:applytemplates select="//*">
<xsl:sort select="namespaceuri()"/>
<xsl:sort select="localname()"/>
</xsl:applytemplates>
</table></body></html>
</xsl:template>
<xsl:template match="*">
<xsl:variable name="">
<xsl:choose>
<xsl:when test="contains(name(), ':')">
<xsl:valueof select="substringbefore(name(),':')"/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<tr>
<td><xsl:valueof select="name()"/></td>
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="localname()"/></td>
<td><xsl:valueof select="namespaceuri()"/></td>
</tr>
</xsl:template>
</xsl:transform>
. 7.3 .xsl
concat() (. . 500),
.
572
7.
. 7.3.
.
localname() . 564
namespaceuri() . 572
namespaceuri
namespaceuri() , URI
. , ,
,
xmlns xmlns:*.
, ,
namespaceuri(document('')/*),
http://www.w3.org/1999/XSL/Transform.
XPath, 4.1
namespaceuri()
namespaceuri()
573
namespace5uri
( ,
)
. ,
( )
. ,
.
,
.
,
.
: URI
.
URI
:
URI
, .
, XML,
, URI
, .
URI
. , .
, XML,
, URI
, .
.
, .
, .
, .
, .
namespaceuri() ,
.
574
7.
,
.
,
,
:*. , ,
http://ibm.com/ebiz, :
<xsl:if test="self::ebiz:*" xmlns:ebiz="http://ibm.com/ebiz">
URI
.
,
:
XSLT extensionelementprefixes, ,
, XML.
, @value (
), URI
:
<xsl:variable name="" select="substringbefore(@value, ':')"/>
<xsl:variable name="nsuri" select="string(namespace::*[name()=$])"/>
namespaceuri(), , ,
URI
. , ,
, URI
urn:schemas.biztalk, ,
.
:
<xsl:if test="startswith(namespaceuri(), 'urn:schemas.biztalk')>
URI
, ,
:
<xsl:template match="*">
<xsl:variable name="uri" select="namespaceuri()"/>
URI : <xsl:valueof select="$uri"/>
<xsl:valueof
select="name(ancestororself::*[namespace::*=$uri][last()])"/>
</xsl:template>
575
normalize5space
.
localname() . 564
name() . 566
normalizespace
normalizespace()
.
, normalizespace(' x	 y ')
x y.
XPath, 4.2
normalizespace()
normalizespace()
(
)
. ,
,
string().
.
,
,
.
XML
, , (#x9,
#xA, #xD #x20).
576
7.
normalizespace()
,
,
.
, <xsl:stripspace>
. ,
.
, normalizespace()
,
. ,
:
<p> <i></i> HTML</p>
, , ,
.
:
<xsl:key name="" match="" use="normalizespace()"/>
:
<xsl:foreach select="key('', normalizespace($))">
, ,
, ,
:
<>
<>
</>
</>
normalizespace()
, .
,
, XSLT 1.0
(, XSLT 1.1
).
substringbefore()
. ,
normalize5space
577
. ,
.
normalizespace()
.
: normalizespace()
,
.
.
XML
. , .xml,
. 550.
.xsl ,
. normalize
space()
. ,
, (
),
.
,
,
.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template name="">
<xsl:param name=""/>
<xsl:variable name="" select="normalizespace($)"/>
<xsl:choose>
<xsl:when test="$">
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name=""
select="substringafter($, ' ')"/>
</xsl:calltemplate>
</xsl:variable>
<xsl:valueof select="$ + 1"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
578
7.
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:foreach select="//*">
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="."/>
</xsl:calltemplate>
</xsl:variable>
< ="{name()}" ="{$}"/>;
</xsl:foreach>
</xsl:template>
</xsl:transform>
.xml :
<
<
<
<
<
<
<
<
<
<
="" ="93"/>;
="" ="32"/>;
="" ="1"/>;
="" ="1"/>;
="" ="30"/>;
="" ="61"/>;
="" ="1"/>;
="" ="1"/>;
="" ="59"/>;
="i" ="2"/>;
.
concat() . 498
substringafter() . 599
substringbefore() . 601
not
not() :
, , .
, not(true()) .
XPath, 4.3
579
not
not()
.
,
, boolean().
:
.
,
,
boolean().
( ) , not() ;
, not() .
, not($A=2) $A!=2.
, $A : not($A=2)
, $A , 2,
$A!=2 , $A ,
2. , $A , not($A=2)
, $A!=2 .
: ,
, go (
no, go),
. go,
.
1: <xsl:if test="@go!='no'">go</xsl:if>
2: <xsl:if test="not(@go='no')">go</xsl:if>
, , =
!= : $X=$Y
(x $X, y $Y) ,
.
size 0,
: not(@size!=0).
580
7.
,
:
<xsl:if test="not(node())">
,
, :
<xsl:if test="not(parent::node())">
<xsl:foreach>
, <>:
<xsl:foreach select="*[not(self::)">
,
:
<xsl:if test="not(.)">
, name
:
<xsl:if test="not(string(@name))">
, name
$ns name
(, ):
<xsl:if test="not($ns[1]/@name = $ns[position()!=1]/@name)">
.
boolean() . 495
false() . 528
true() . 613
number
number() .
, number(' 17.3') 17.3.
XPath, 4.4
581
number
number()
number()
(
)
, .
.
, .
.
XPath, XPath;
(NaN)
, string(),
,
(. )
,
number().
, ,
. ,
. , ,
.
, , ,
, ,
.
<xsl:applytemplates select="$[number(@)]"/>
582
7.
, (, ) ,
number() ,
NaN ().
:
<xsl:if test="string(number(@))='NaN'"/>
number(12.3)
12.3
number("12.3")
12.3
number(true())
1.0
number("xyz")
NaN
number("")
NaN
.
boolean() . 495
formatnumber() . 531
string() . 591
<xsl:number> 4
position
position() .
position() ,
, .
XPath, 4.1
position()
, . ,
.
position
583
XPath position()
(context position). XSLT
: (current node)
(current node list).
( ,
),
.
(1). :
( use
<xsl:key>),
(), 1.
,
.
<xsl:applytemplates>
,
,
1, 2, n .
, ,
,
.
<xsl:foreach>
, ,
1,
2, n .
, ,
, .
position() select
<xsl:sort>, . ,
, ,
, :
<xsl:sort select="position()" datatype="number"
order="descending">
last() . 559
,
.
(
),
,
. 5
6 .
584
7.
position()
.
position()
<xsl:number>
, .
<xsl:number>, position() :
,
<xsl:number>
. , <xsl:number>
, <xsl:sort>.
position()
<xsl:number> . :
<xsl:number value="position()" format="(a)"/>
:
(a), (b), (c) . .
<xsl:if> <xsl:when>
.
. ,
, .
:
<xsl:foreach select="">
<xsl:sort select="@"/>
<p><xsl:valueof select="@"/>:
<xsl:valueof select=""/></p>
<xsl:if test="position() != last()">
<hr/>
</xsl:if>
</xsl:foreach>
( )
position().
, item[1] item[position()=1], item[last()]
item[position()=last()].
position
585
,
. ,
,
: 0 ,
. , <xsl:if test="1"> <xsl:if test=
"position()=1">; , <xsl:if test="true()">.
: position()
.xml :
<>
< ="10" ="30"/>
< ="15"/>
< ="3" ="80"/>
< ="10"/>
</>
.xsl
.
.
<xsl:applytemplates>,
, . ,
.
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="" mode="">
<xsl:valueof select="@ * @"/>
</xsl:template>
<xsl:template match="" mode="">
<xsl:valueof select="@ * @"/>
</xsl:template>
<xsl:template match="" mode="">
<xsl:valueof select="3.14159 * @ * @"/>
</xsl:template>
<xsl:template name="">
<xsl:param name=""/>
586
7.
<xsl:choose>
<xsl:when test="$">
<xsl:variable name="">
<xsl:applytemplates select="$[1]"
mode=""/>
</xsl:variable>
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name=""
select="$[position()!=1]"/>
</xsl:calltemplate>
</xsl:variable>
<xsl:valueof select="$ + $"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="*"/>
</xsl:calltemplate>
</xsl:template>
</xsl:transform>
Saxon :
1079.159
,
formatnumber()
0.0.
.
last() . 559
<xsl:number> 4
round
round() ,
.
, round(4.6) 5.
XPath, 4.4
587
round
round()
. ,
,
, number().
:
.
,
.
number() . 580. ,
, .
XPath ro
und(). .
,
2.
N N+0.5
N+0.5
N+1
N+0.5 N+1
N+1
0.5
NaN ()
NaN
588
7.
round() , ,
,
.
: round()
HTML,
.
,
.
.xml:
<>
<>Windows 98
< ="1">82</>
< ="2">64</>
< ="3">58</>
</>
<>Windows NT
< ="1">17</>
< ="2">44</>
< ="3">82</>
</>
</>
.xsl .
:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:template match="">
<html><body>
<h1> </h1>
<xsl:variable name="" select="count([1]/)"/>
<table border="1" cellpadding="5" width="100%">
<tr>
<th width="50%"></th>
<xsl:foreach select="[1]/">
<th width="{round(50 div $)}%">
589
starts5with
<xsl:valueof select="@"/>
</th>
</xsl:foreach>
</tr>
<xsl:foreach select="">
<tr>
<td><xsl:valueof select="text()"/></td>
<xsl:foreach select="">
<td>
<xsl:valueof select="."/>
</td>
</xsl:foreach>
</tr>
</xsl:foreach>
</table>
</body></html>
</xsl:template>
</xsl:transform>
. 7.4.
.
ceiling() . 497
floor() . 529
startswith
startswith() , .
, startswith('$17.30', '$') .
XPath, 4.2
590
7.
startswith(, )
, .
,
,
string().
,
. ,
,
string().
: , ,
.
, .
, ,
; .
, Unicode.
, .
, ,
. ,
.
startswith()
,
. , <link>,
href , #:
<xsl:template match="link[startswith(@href, '#')]">
. . .
</xsl:template>
endswith(). ,
$A $B:
substring($A, stringlength($A) stringlength($B) + 1) = $B
591
string
.
contains() . 501
stringlength() . 593
string
string() .
, string(4.00) 4.
XPath, 4.2
string()
string()
(
)
. ,
,
.
: .
.
.
.
.
NaN.
0.
Infinity.
Infinity.
. ;
592
7.
, .
XPath.
,
. ,
,
.
,
IEEE 754.
XPath.
, .
,
, .
.
.
.
URI
.
.
,
.
, , <xsl:variable name=
"v"></xsl:variable>, ,
, .
,
, ,
.
.
, , ,
,
. XSLT 1.0 1.1;
XSLT 1.0 ,
, .
string(),
, .
593
string5length
, .
, .
, ,
<> . . .
<xsl:if test="='. . '">
,
<> ( )
:
<xsl:if test="string()='. . '">
:
<xsl:if test="[1]='. . '">
.
boolean() . 495
number() . 580
stringlength
stringlength() .
, stringlength('') 8.
XPath, 4.2
stringlength()
stringlength()
(
)
, .
, ,
,
string().
.
594
7.
(Char)
XML. , Unicode ( 16 ,
Unicode #x10000
#x10FFFF) .
,
. ,
ÿ &, .
Unicode
, ,
.
, .
, , ,
. stringlength()
.
stringlength()
. ,
, ,
.
, ,
stringlength(),
, boolean(), ,
,
, .
stringlength()
,
.
stringlength()
:
stringlength('')
stringlength('')
stringlength('<>')
stringlength('�')
stringlength('𠀀')
595
substring
.
substring()
substring
substring() ,
. .
, substring('', 6, 3) .
XPath, 4.2
substring(, )
substring(, , )
. ,
,
, string().
,
. ,
,
, number().
(
)
, .
, ,
,
number().
,
.
: .
, ,
, ;
, ,
.
596
7.
1, 2, 3 n.
Visual Basic, , C Java,
.
(Char)
XML. , Unicode ( 16 ,
Unicode #x10000
#x10FFFF) .
Unicode
, ,
.
, .
, , ,
.
,
, , NaN, ,
(
2). :
.
( ).
,
, p
:
p >= round()
round(),
. 586.
IEEE 754,
,
. IEEE 754
2.
, ,
,
, .
, ,
.
, .
substring
597
substring() .
:
<xsl:variable name="">
<xsl:if test="substring($,2,1)=':')">
<xsl:valueof select="substring($,1,1)"/>
</xsl:if>
</xsl:variable>
(, ,
):
<xsl:variable name="">
<xsl:valueof select=""/>
<xsl:text> </xsl:text>
<xsl:valueof select="substring(, 1, 1)"/>
<xsl:text> </xsl:text>
<xsl:valueof select=""/>
</xsl:variable>
, ,
substring() stringlength(). ,
:
<xsl:variable name="">
<xsl:if test="substring(@href, stringlength(@href)3) = '.xml'">
<xsl:valueof select="document(@href)"/>
</xsl:if>
</xsl:variable>
,
#x#, x :
<xsl:if test="contains($s, '#') and
substring(substringafter($s, '#'), 2, 1)='#'">
substring()
. , $b .
:
substring("xyz", 1, $b * stringlength("xyz"))
$b ,
: 0 , 1 . ,
0, $b , 3, $b .
, substring(), ,
, $b , "xyz", $b
. ($b ? "xyz" : "")
Java C.
598
7.
, ,
. , ,
. :
substring("xyz", 1, $b * 1000)
:
substring("xyz", 1, $b * (1 div 0))
, 1 div 0 .
HTML.
,
( item), ,
( ) .
<xsl:choose>, :
concat(item, substring(' ', 1, not(item))
(<xsl:key>) (<xsl:sort>),
XPath XSLT
. , ,
, :
<>
<
<
<
<
<
</>
="GBP"
="GBP"
="USD"
="GBP"
="USD"
="14.00"/>
="18.00"/>
="23.50"/>
="12.00"/>
="17.80"/>
:
<xsl:variable name="" select="1.53"/>
<xsl:foreach select="">
<xsl:sort datatype="number"
select="concat(
substring(@ * $, 1, (@='USD') *
1000),
substring(@, 1, (@='GBP') * 1000))"/>
</xsl:foreach>
</xsl:variable>
, ,
, .
599
substring5after
.
substringafter()
substringbefore() . 601
stringlength() . 593
contains() . 501
substringafter
substringafter() ,
.
, substringafter('print=yes', '=')
yes.
XPath, 4.2
substringafter(, )
. ,
, ,
string().
. ,
,
, string().
, ,
.
,
. ,
,
.
contains().
600
7.
,
, ,
.
,
.
, .
substringafter() , ,
. ,
, ,
substringbefore($s, ' ')
:
substringafter($s, ' ')
normalizespace(),
, concat()
,
, .
,
, , <br/>.
<xsl:template name="">
<xsl:param name=""/>
<xsl:variable name=""
select="concat(normalizespace($),' ')"/>
<xsl:variable name="" select="substringbefore($, ' ')"/>
<xsl:variable name="" select="substringafter($, ' ')"/>
<xsl:valueof select="$"/>
<xsl:if test="$">
<br/>
<xsl:calltemplate name="">
<xsl:withparam name="" select="$"/>
</xsl:calltemplate>
</xsl:if>
</xsl:template>
.
contains() . 501
substring() . 595
substringbefore()
601
substring5before
substringbefore
substringbefore() ,
.
, substringbefore('print=yes', '=')
print.
XPath, 4.2
substringbefore(, )
. ,
, ,
string().
. ,
,
, string().
, ,
.
,
. , ,
.
startswith().
,
, ,
.
,
.
substringafter() substringbefore()
, ,
substringafter() . 599.
602
7.
substringbefore()
,
startswith(). :
<xsl:if test="substringbefore($url, ':')='https'">
:
<xsl:if test="startswith($url, 'https:')">
substringbefore() substringafter()
. translate()
. ,
contains(), substringbefore(), substringafter() ,
, concat(). .
:
.
, .
. ,
.xml = =.
.xsl
,
,
. ,
.
,
. .
Saxon :1
saxon .xml .xsl =xxx =yyy
Xalan ( ):
java org.apache.xalan.xslt.Process in .xml xsl
.xsl param xxx param yyy
1
,
, ,
, ,
.
,
ASCII. . . .
substring5before
603
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:param name=""/>
<xsl:param name=""/>
<xsl:template name="">
<xsl:param name=""/>
<xsl:choose>
<xsl:when test="contains($, $)">
<xsl:valueof select="substringbefore($, $)"/>
<xsl:valueof select="$"/>
<xsl:calltemplate name="">
<xsl:withparam name=""
select="substringafter($, $)"/>
</xsl:calltemplate>
</xsl:when>
<xsl:otherwise>
<xsl:valueof select="$"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copyof select="@*"/>
<xsl:applytemplates/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:calltemplate name="">
<xsl:withparam name="" select="."/>
</xsl:calltemplate>
</xsl:template>
</xsl:transform>
.xml =
=*** :
<>
< =". ">
<>1852</>
<>1956</>
<>
. *** , , ,
. .</>
604
7.
</>
< =" ">
<>1881</>
<>1972</>
<> ( ) <i>
</i>, , .
1919,
, . *** . .
, ***, ,
.</>
</>
</>
.
contains() . 501
startswith() . 589
substring() . 595
substringafter() . 599
sum
sum() ,
.
, , <rect x="20" y="30"/>,
sum(@*) 50. ( @* ,
.)
XPath, 4.4
sum()
,
. ,
.
sum
605
. ,
.
, number().
,
IEEE 754.
,
, sum() .
.
sum()
,
.
,
,
, , . ,
<>
, ,
? ,
$, ?
, sum()
.
sum():
; ( ,
) .
( ),
.
,
. ,
.
. 585.
( XSLT 1.1
nodeset(), XSLT 1.0)
, .
, ,
, sum()
.
606
7.
:
count() sum()
(
A 1998 ).
.xml:
< ="A">
<>
<>10Jun98</>
< ="2"></>
< ="1"></>
</>
<>
<>10Jun98</>
< ="2"></>
< ="2"></>
</>
<>
<>16Jun98</>
< ="1"></>
< ="1"></>
</>
<>
<>16Jun98</>
< ="3"></>
< ="0"></>
</>
<>
<>23Jun98</>
< ="1"></>
< ="2"></>
</>
<>
<>23Jun98</>
< ="0"></>
< ="3"></>
</>
</>
.xsl.
: ,
<>
( <>,
607
sum
, ),
, <>.
,
, , ,
, .
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:variable name="" select="//[not(.=preceding::)]"/>
<xsl:variable name="" select="//"/>
<xsl:template match="">
<html><body>
<h1> <xsl:valueof select="@"/></h1>
<table cellpadding="5">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
<td> </td>
</tr>
<xsl:foreach select="$">
<xsl:variable name="" select="."/>
<xsl:variable name="" select="count($[=$])"/>
<xsl:variable name="" select="count($[[.=$]/
@ > [.!=$]/@])"/>
<xsl:variable name="" select="count($[[.=$]/
@ < [.!=$]/@])"/>
<xsl:variable name="" select="count($[[.=$]/@ =
[.!=$]/@])"/>
<xsl:variable name="" select="sum($/[.=current()]/@)"/>
<xsl:variable name="" select="sum($[=current()]/
/@) $"/>
<tr>
<td><xsl:valueof select="."/></td>
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="$"/></td>
<td><xsl:valueof select="$"/></td>
</tr>
</xsl:foreach>
</table>
</body></html>
608
7.
</xsl:template>
</xsl:transform>
. 7.5. A
.
count() . 502
systemproperty
systemproperty() ,
.
, XSLT 1.1
systemproperty('xsl:version') 1.1.
XSLT, 12.4
systemproperty()
,
. ,
,
, string().
,
.
, .
609
system5property
, , ,
.
,
systemproperty().
,
, XSLT.
xsl:version
, XSLT,
.
1.0 1.1. , ,
<xsl:valueof>
1 1.1.
xsl:vendor
, .
,
. MSXML3 Microsoft
Microsoft.
xsl:vendorurl
: URL . , MSXML3
http://www.microsoft.com.
.
, ,
, .
XSLT ,
. ,
, .
systemproperty()
, ,
(, ),
.
.
functionavailable() elementavailable(),
<xsl:fallback>,
, XSLT,
610
7.
,
3.
, systemproperty('xsl:version')
, .
XSLT 1.1, ,
(
XSLT 1.0) , <xsl:foreach>
<xsl:applytemplates>.
XSLT,
, XSLT
. XSLT 1.0
, , ,
msxml:nodeset().
:
<xsl:variable name="">
. . .
</xsl:variable>
<xsl:choose>
<xsl:when test="systemproperty('xsl:version') >= 1.1">
<xsl:applytemplates select="$"/>
</xsl:when>
<xsl:when test="functionavailable('msxml:nodeset')">
<xsl:applytemplates select="msxml:nodeset($)"/>
</xsl:when>
<xsl:when test="functionavailable('xt:nodeset')">
<xsl:applytemplates select="xt:nodeset($)"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes"> </
xsl:message>
</xsl:otherwise>
</xsl:choose>
HTML
:
<HTML>
<xsl:comment> XSLT abc.xsl
<xsl:valueof select="systemproperty('xsl:vendor')"/>
XSLT
<xsl:valueof select="systemproperty('xsl:version')"/>
</xsl:comment>
. . .
611
translate
.
elementavailable() . 522
functionavailable() . 535
<xsl:fallback> 4
translate
translate()
.
.
, translate('ABC123', '', '/')
ABC/123.
XPath, 4.2
translate(, , )
. ,
, ,
string().
, .
, ,
,
string().
. ,
,
, string().
, .
.
612
7.
:
, ,
.
P ,
, ,
P, P
.
P ,
, , P,
.
, ,
.
, .
,
, ,
( ).
, .
XML, 16 Uni
code. , Unicode ( 16
, Unicode
#x10000 #x10FFFF) .
translate()
,
. ,
,
:
translate($X,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
translate()
: ,
, , :
translate($X, ' 	

()', '')
translate()
. ,
ASCII:
contains(translate($X, '0123456789', '9999999999'), '999')
true
613
substringafter() substringbefore()
.
, / \,
( ):
substringbefore(translate($X, '\', '/'), '/')
.
contains() . 501
substring() . 595
substringafter() . 599
substringbefore() . 601
true
.
XPath, 4.3
true()
XPath ,
true() false().
.
<xsl:withparam>. .
<xsl:when test="true()"> ,
(
, ).
614
7.
, :
<xsl:calltemplate name="">
<xsl:withparam name="" select="true()"/>
</xsl:calltemplate>
.
false(), . 528
unparsedentityuri
unparsedentityuri()
DTD .
, , DTD :
<!ENTITY SYSTEM ".jpeg" NDATA JPEG>
unparsedentityuri('') URI
weather.jpeg,
URI DTD.
XSLT, 12.4
unparsedentityuri()
,
.
,
, string().
XML.
, URI ( )
, .
.
unparsed5entity5uri
615
, ,
, ,
URI .
, .
URI, XSLT
URI
.
DTD
:
<!ENTITY SYSTEM ".jpeg" NDATA JPEG>
NDATA ( XML)
.
&;,
ENTITY ENTITIES, :
< ="">.
, , ,
ENTITY (XSLT ),
unparsedentityuri(@).
URI ,
, file:\c:\\\.jpeg.
, , HTML <IMG>
.
XSLT (
JPEG) URI ,
, .
4.4.6 XML,
:
ENTITY ENTITIES,
. ,
XML,
XSLT .
, XSLT,
, ,
,
XSLT ,
DTD, ,
unparsedentityuri() .
XML
, .
616
7.
<!ENTITY SYSTEM ".jpeg" NDATA JPEG>
< =""/>
<IMG> HTML:
<xsl:template match="">
<IMG HREF="{unparsedentityuri(@)}"/>
</xsl:template>
.
, 2.
, XSLT,
. ,
XSLT, ,
, XPath.
XSLT . 8
Java Java
Script.
XSLT
XPath. ,
XML. ,
,
, , .
XSLT 1.1
, ,
Java JavaScript (
ECMAScript). , C++, Visual Basic
Perl, ,
.
XSLT 1.0
. ,
, ,
. ,
XSLT 1.1.
.
XSLT 1.1
Java JavaScript.
, , ,
XSLT. ,
Java JavaScript, , ,
. ,
Java,
Saxon, Xalan Oracle XSL,
JavaScript, Microsoft, Xalan Unicorn.
618
8.
,
XSLT.
, , .
XSLT 1.1 ,
.
.
,
,
. ,
, ,
.
XSLT 1.0,
, , .
?
,
:
, ,
.
,
XSLT XPath. ,
,
.
SVG ,
sin() cos().
,
XSLT .
. XSLT
,
, .
XSLT, ,
.
, ,
XSLT .
.
, , .
Java JavaScript
619
, , ,
,
. , ,
, .
,
. , Java,
Java.
MSXML3 Microsoft
Microsoft. 4XSLT,
, , Python. ,
C++,
, .
XPath,
5.
:
my:function($arg1, 23, string(title))
. (, my)
.
( ), ,
. XPath.
,
, .
, .
.
.
?
(
), .
, Xalan Ja
va JavaScript, Microsoft
, JScript VBScript.
, Java Oracle, Saxon Xalan, JScript
MSXML3, Python 4XSLT.
620
8.
,
.
,
JavaScript,
, , XPath,
. , Java
, .
XPath my:function,
XSLT .
(binding).
<xsl:script>, ,
. <xsl:script>
4.
,
URI . <xsl:script>,
implementsprefix URI
, , .
<xsl:script> ,
:
, .
<xsl:script> , ,
language java, javascript,
,
.
, ,
, , ,
, Java,
JavaScript. ,
.
, ( )
, .
,
. Java
, ,
. JavaScript
( , ),
.
.
Java JavaScrit,
XPath
621
, , XPath
(DOM).
XPath
DOM (Do
cument Object Model, ),
,
XML. DOM
(, , API) XML
.
,
XSLT
document(), , ,
XSLT, ,
.
DOM.
( DOM Document)
XPath, ,
, XSLT document().
, ,
, XSLT XPath, ,
DOM. , DOM
CDATA, XPath .
,
, XSLT:
. , MSXML3 Microsoft,
DOM. Microsoft
DOM, XPath
() . , , CDATA
, XPath, followingsibling,
CDATA
.
DOM CDATA
. (, Saxon)
, XPath,
. ,
XPath, CDATA
.
: DOM
XPath.
622
8.
.
, DOM , ,
, , ,
XPath, XPath. ,
XPath, ,
, . ,
, ,
DOM, ,
.
, XPath
( ) ,
DOM . (
MSXML3
, XPath .)
, ,
,
. XSLT 1.1
DOM
XPath :
XPath
DOM
Document
Element
Attr
XPath
xmlns
xmlns:*. DOM Attr
, .
,
DOM, .
getSpecified DOM
.
Text
DOM
.
CDATA, CDATA
, DOM.
,
DOM, .
, ,
XSLT,
DOM.
XPath
623
XPath
DOM
DOM ,
XPath. DOM
URI ,
.
CDATASection
CDATASection
( CDATA) DOM,
, ,
,
DOM XPath.
, DOM,
DOM, XPath. , XPath
,
DOM nodeValue() null.
, DOM,
,
. :
DOM .
DOM XPath,
, , .
DOM XPath
,
XSLT. , ,
, XSLT.
DOM
.
Node NodeList
DOM, :
DOM,
, Document
DocumentFragment.
,
XPath,
624
8.
, DOM
XPath
.
, XPath,
Node, .
,
,
document().
,
DOM (, Oracle DOM,
Xerces).
: ,
DocumentFragment, ownerDocu
ment Document,
ownerDocument XSLTContext.
,
,
,
, xmlns:*. ,
, .
XSLT, ,
.
XPath
, , , .
XSLT, .
, XSLT
XPath,
.
.
JavaScript, ,
XPath
. ,
my:toUpperCase() ,
my:toUpperCase(@desc), my:toUpperCase(string(@desc)).
. Java
.
,
,
document() URIResolver,
URI, ,
. TrAX, F,
.
,
DOM ownerDocument XSLTContext.
Java
625
DocumentFragment, ,
.
DocumentFragment,
Node NodeList .
Java
XPath Java. Java
.
, Java, :
XPath
Java.
XPath ,
, ,
.
Java.
,
.
.
Java
:
,
Java .
, ,
,
.
, Java,
, . ,
, , ,
SQL .
,
Java.
, ,
. ,
Java XSLT
XPath, . 642.
Java
,
, my:function().
,
626
8.
,
URI .
, xmlns:my="http://
schmidt.de/functions", URI ,
.
URI ,
, xmlns:math=java:java.lang.Math.
,
.
, , .
<xsl:script>, implementsprefix
, URI . ,
,
URI .
<xsl:script>
language java, src <xsl:script>
Java, java: ,
URI.
, :
<xsl:valueof select="dt:new()"/>
<xsl:script>:
<xsl:script language="java" implementsprefix="dt" src="java:java.util.Date"/>
, Java
java.util.Date. .
,
archive, ,
,
.
<xsl:script>,
.
<xsl:script> , .
Java
XPath
.
new,
, ,
. :
, , ,
, . ,
Java
627
XPath acct:getaccountnumber(),
Java, getAccountNumber().
,
. ,
getAccountNumber(), acct:getAccountNumber(),
.
. , .
, Java
(
), , ,
.
. ,
, . ,
:
Java
org.w3c.xsl.XSLTContext, .
, . 642,
XPath.
Java (
), XPath
,
.
, .
.
,
XPath.
XPath ,
,
.
XPath
Java.
,
. Ja
va. ,
, , ,
.
XPath Java
: ,
, , . ,
628
8.
(
). XPath A, Java
P, A P:
, (A, P). , . 629, ,
, , (, double)=0 (, String)=16.
, XPath A1, A2
A3, Java: P
P1, P2 P3 Q Q1, Q2, Q3.
,
. , ,
, .
n=1..3 ( ) Pn
, Qn, (An, Pn) < (An, Qn),
P Q. (
,
Java , .)
, (An, Pn) < (An, Qn), ,
(Am, Pm) > (Am, Qm), , P Q,
.
, , .
, .
, ,
date:compare('20010405', '20011011')
:
A
compare(int, int)
compare(int, String)
compare(String, int)
compare(String, String)
D ,
. ,
, ,
( . 629), :
629
Java
D, D, ,
. D.
A, B C,
, C
, B . ,
D , .
XPath ( ) Java. XPath
, Java
.
, , .
,
String , Float,
.
boolean
14
Boolean
15
byte
12
Byte
13
char
10
Character
11
double
Double
float
Float
int
Integer
long
Long
630
8.
Node
( 1)
NodeList
Object
17
0
( 2)
short
Short
String
16
1: DOM org.w3c.dom.Node .
NodeList DOM org.w3c.dom.NodeList.
2: ,
.
, , ,
.
,
,
, . , ,
XPath byte Java?
,
XPath .
XPath
boolean Boolean
Object
Boolean: Boolean.TRUE,
Boolean.FALSE.
String
true false.
XPath
double, Double
631
Java
float, Float
,
float. ,
float,
.
bo
olean() XPath false,
true.
String
string() XPath.
Object
Double.
XPath
String
Object
String.
char, Character
,
.
, .
XPath XPath
number(),
Java,
.
boolean, Boolean
false,
true.
XPath
org.w3c.dom.NodeList
NodeList DOM.
. ,
.
org.w3c.dom.Node
org.w3c.dom.Attr
org.w3c.dom.CDATASection
org.w3c.dom.CharacterData
, .
( ),
. ,
(,
632
8.
org.w3c.dom.Comment
,
Document).
org.w3c.dom.Document
org.w3c.dom.Element
org.w3c.dom.ProcessingInstruction
org.w3c.dom.Text
String
string() XPath. (
,
, ,
.)
Object
org.w3.dom.No
deList.
char, Character
string() XPath.
, ,
.
false,
, true,
.
Java C, , .
OBJ instanceof C ,
OBJ .
String
toString()
.
char, Character
toString()
. ,
,
.
633
Java
Java , .
. , ,
, : ()
,
, ()
.
, ,
Java,
, , ,
1.
, XPath
. (
,
,
. 640.)
Java null, XPath
, null. ,
null,
. , Java
, , ,
null. Java API
, , ,
identityHashCode() java.lang.System, ,
null. :
<xsl:stylesheet...
xmlns:sys="java:java.lang.System"
xmlns:my="java:name.joeprogrammer.ExtensionClass">
<xsl:script language="java" implementsprefix="sys"
src="java:java.lang.System"/>
. . .
<xsl:variable name="result" select="my:method($x)"/>
<xsl:if test="sys:identityHashCode($result) = 0">
<xsl:message> my:method() null</xsl:message>
</xsl:if>
XPath
:
, Java XPath
String
.
, ,
,
Java, XML, ,
634
8.
, Java XPath
NUL ASCII (#x00).
,
,
.
double, float, long, int, short, byte, XPath.
Double, Float, Long, Integer, Short, Byte
boolean, Boolean
XPath.
DOM,
. , Oracle XSLT
DOM, XML Xer
ces: DOM,
Oracle.
,
DOM?
XPath ( ,
generateid()) XPath?
, DOM
, , , ,
. ,
DOM
,
, , Java DOM
, DOM
Java DOM
, ,
.
XSLT
NodeList Node,
, ,
, .
Java
,
, , ,
, .
, .
Java
635
: ,
.
, .
,
.
max(a, b),
java.lang.Math.
.
:
<xsl:script implementsprefix="Math" xmlns:math="java:java.lang.Math"
language="java" src="java:java.lang.Math"/>
. . .
<xsl:template match="price">
<xsl:valueof select="Math:max(number(@netprice), number(@grossprice))"
xmlns:Math="java:java.lang.Math"/>
</xsl:template>
Java ,
( java:) URI . ,
, URI,
.
java.lang.Math
max(),
double, float, int long, .
double double,
.
, XPath.
number() ,
. . 629, ,
XPath Java double, float, long
int . ,
, .
, max(),
XSLT, . ,
,
.
.
, .
636
8.
Java ,
new().
Java,
XPath , . ,
.
( ).
,
XPath, , .
, , . ja
va.util.Date , Date,
,
toString(), Sat Jan 06 14:32:29 GMT 2001.
substring() XPath ,
.
, :
<xsl:script language="java" implementsprefix="Date"
src="java:java.util.Date" xmlns:Date="java:java.util.Date"/>
...
<xsl:template match="/">
<xsl:variable name="date" select="Date:toString(Date:new())"
xmlns:Date="java:java.util.Date"/>
<xsl:comment> <xsl:valueof select="
concat(substring($date, 12, 5), ' ',
substring($date, 9, 2), ' ',
substring($date, 5, 3), ' ',
substring($date, 25, 4))"/></xsl:comment>
. . .
</xsl:template>
:
<! 14:32 06 Jan 2001>
: Date:new(),
java.util.Date
Date, Date:toString(),
. Da
te:toString() ,
XPath Date, Date
.
, ,
XPath .
,
,
Java
637
.
,
XPath: , ,
, .
XPath
,
XSLT,
.
, ,
, .
.
.
Java BufferedReader
,
<br/>.
:
,
XML. ,
.
,
. ,
hiawatha.txt:1
, ,
,
, ,
, ,
.
,
,
,
,
!
reader.xsl.
1
. . . . .
638
8.
.
<xsl:script> XSL,
,
<xsl:stylesheet>.
URI java:*
Java URI
,
. ,
,
excluderesultprefixes.
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:FileReader="java:java.io.FileReader"
xmlns:BufferedReader="java:java.io.BufferedReader"
xmlns:System="java:java.lang.System"
excluderesultprefixes="FileReader BufferedReader System">
<xsl:script language="java" implementsprefix="FileReader"
src="java:java.io.FileReader"/>
<xsl:script language="java" implementsprefix="BufferedReader"
src="java:java.io.BufferedReader"/>
<xsl:script language="java" implementsprefix="System"
src="java:java.lang.System"/>
:
<xsl:param name="filename"/>
,
BufferedReader.
:
<xsl:template match="/">
<out>
<xsl:variable name="reader"
select="BufferedReader:new(FileReader:new($filename))"/>
<xsl:calltemplate name="readlines">
<xsl:withparam name="reader" select="$reader"/>
</xsl:calltemplate>
</out>
</xsl:template>
,
.
, readLine() BufferedReader
null, , XPath
, Java null.
System.identityHashCode(),
: , null.
<xsl:template name="readlines">
<xsl:param name="reader"/>
Java
639
,
. :
somexsltproc reader.xsl reader.xsl filename=hiawatha.txt
( , XSLT ,
XSLT
XSLT 1.1,
,
.)
:
<out>
, ,<br/>
,<br/>
, ,<br/>
, ,<br/>
.<br/>
<br/>
, <br/>
,<br/>
,<br/>
,<br/>
!<br/>
</out>
,
$reader Java,
. ,
XSLT .
, XSLT
, ,
. , readlines
<xsl:if>, $line,
, , ,
,
.
640
8.
,
.
.
,
, XML.
,
.
,
, addresses.txt. ,
.
,
, , .
, ****,
.
15668
Mary Cousens
15 Birch Drive
Wigan
01367844355
17796
John Templeton
17 Spring Gardens
Wolverhampton
01666932865
19433
Jane Arbuthnot
92 Mountain Avenue
Swansea
01775952266
****
(addresses.xsl), :
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"
xmlns:FileReader="java:java.io.FileReader"
Java
641
xmlns:BufferedReader="java:java.io.BufferedReader"
xmlns:System="java:java.lang.System"
excluderesultprefixes="FileReader BufferedReader System">
<xsl:script language="java" implementsprefix="FileReader"
src="java:java.io.FileReader"/>
<xsl:script language="java" implementsprefix="BufferedReader"
src="java:java.io.BufferedReader"/>
<xsl:script language="java" implementsprefix="System"
src="java:java.lang.System"/>
<xsl:template match="/">
<xsl:variable name="reader"
select="BufferedReader:new(FileReader:new($filename))"/>
<xsl:calltemplate name="readaddresses">
<xsl:withparam name="reader" select="$reader"/>
</xsl:calltemplate>
</xsl:template>
<xsl:template name="readaddresses">
<xsl:param name="reader"/>
<xsl:variable name="line1" select="BufferedReader:readLine($reader)"/>
<xsl:if test="$line1 != '****'">
<xsl:variable name="line2" select="BufferedReader:readLine($reader)"/>
<xsl:variable name="line3" select="BufferedReader:readLine($reader)"/>
<xsl:variable name="line4" select="BufferedReader:readLine($reader)"/>
<xsl:variable name="line5" select="BufferedReader:readLine($reader)"/>
<label>
<address>
<xsl:valueof select="$line3"/><br/>
<xsl:valueof select="$line4"/><br/>
</address>
<recipient>Attn: <xsl:valueof select="$line2"/></recipient>
</label>
<xsl:calltemplate name="readlines">
<xsl:withparam name="reader" select="$reader"/>
</xsl:calltemplate>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
? , ,
$line2, $line3, $line4 $line5, ,
. , ,
. ,
, ,
, $line3 ,
$line2, , $line5 (
) ,
.
642
8.
XSLT
.
, XSLT.
,
XSLT, .
, , .
, TrAX, Saxon Xalan,
Java,
, SAX2.
URIResolver, , URI
,
document() URI
.
MSXML3 , , ,
DOM. JavaScript,
DOM,
.
,
,
.
XSLTContext
XSLT
,
, XPath XSLT,
,
. XPath;
, , name() generateid(),
, . ,
.
,
Java, ,
org.w3c.xsl.XSLTContext.
XSLTContext .
, ,
Java,
, java.lang.IllegalArgumentException java.lang.NullPointerException.
org.w3c.dom.Node getContextNode()
Java
643
XPath,
DOM Node: ,
XPath ..
DOM. ,
, (
DOM).
int getContextPosition()
XPath, ,
XPath position().
int getContextSize()
XPath, ,
XPath last().
org.w3c.dom.Node getCurrentNode()
XSLT, DOM
Node, , XPath current().
org.w3c.dom.Document getOwnerDocument()
DOM Document,
. ,
.
createDocumentFragment,
createElement,
createElementNS,
createAttribute,
createAttributeNS, createTextNode, createComment, createProcessingInstruction
importNode. .
Object systemProperty(String namespaceURI, String localName)
, XPath systemproperty().
,
XPath, .
.
String stringValue(org.w3c.dom.Node node)
,
XPath. , ,
, DOM.
,
, ,
"root", "element", "text" . . XPath,
.
package name.joe_programmer.xslt;
import org.w3c.dom.*;
644
8.
import org.w3c.xsl.XSLTContext;
public abstract class Extensions {
public static String nodeType(XSLTContext context) {
Node node = context.getContextNode();
if (node instanceof Document) return "root";
if (node instanceof Element) return "element";
if (node instanceof Attr) return "attribute";
if (node instanceof ProcessingInstruction)
return "processinginstruction";
if (node instanceof Comment) return "comment";
if (node instanceof Text) return "text";
return "unknown node type";
}
}
:
<xsl:stylesheet. . .
xmlns:my="http://joeprogrammer.name/xslt">
<xsl:script implementsprefix="my" language="java"
src="java:name.joe_programmer.xslt.Extensions"/>
. . .
<xsl:template name="atemplate">
<xsl:if test="my:nodetype() = 'attribute'">
<xsl:message terminate="yes"> </xsl:message>
</xsl:if>
. . .
</xsl:template>
, XSLT
XSLTContext.
,
, XSLTContext
. , Saxon
, , (
key() formatnumber()) ,
. , XSLTContext
, .
,
,
:
public static String methodName(XSLTContext context) {
if (context instanceof com.icl.saxon.Context) {
com.icl.saxon.Context saxonContext = (com.icl.saxon.Context)context;
// Saxon
} else if (context instanceof
org.apache.xalan.extensions.ExpressionContext){
org.apache.xalan.extensions.ExpressionContext xalanContext =
JavaScript
645
(org.apache.xalan.extensions.ExpressionContext)context;
// Xalan
} else {
return "*** XSLT: " +
context.systemProperty(
"http://www.w3.org/1999/XSL/Transform", "vendor");
}
}
JavaScript
XSLT 1.1
: Java JavaScript. Java,
JavaScript.
ECMAScript,
JavaScript Netscape, JScript Microsoft.
JavaScript , Java, ,
XSLT JavaScript , Java.
:
JavaScript, XSLT, ,
,
.
JavaScript ,
.
Java,
, JavaScript
.
JavaScript,
XSLT, JavaScript ,
HTML.
, , XSLT
, JavaScript
HTML.
, JavaScript
JavaScript, ,
<xsl:script>,
( .js), src
<xsl:script>. , ,
<xsl:include> <xsl:import> ,
<xsl:script>. ,
JavaScript
.
JavaScript
, JavaScript
646
8.
<xsl:script>
. Java,
<xsl:script> ,
.
JavaScript
, JavaScript,
. , Java
Script , ,
.
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:js="javascript:code">
<xsl:script language="javascript" implementsprefix="js">
function matches(str, regexp) {
return str.match(new RegExp(regexp));
}
</xsl:script>
<xsl:template match="*[js:matches(name(), 'address$')]">
. . .
</xsl:template>
</xsl:stylesheet>
<xsl:template> ,
, address,
billingaddress deliveryaddress.
, ,
;
, .
js,
URI javascript:code,
. , , , URI
,
implementsprefix <xsl:script>, URI
, .
XSLT ,
js:matches(), <xsl:script>,
implementsprefix, .
language <xsl:script>.
<xsl:script>
<xsl:script>,
647
JavaScript
. <xsl:script>
implementsprefix, lan
guage, , ,
.
, <xsl:script>
JavaScript
, .
, XPath,
JavaScript.
, , ,
, . , ,
XPath js:containssamenodes(), Java
Script containsSameNodes().
,
. Java
, , .
,
, .
, ,
, , ,
, .
Java, ,
. , JavaScript, ,
, ,
arguments.
JavaScript
,
XPath, .
XPath JavaScript
:
XPath
JavaScript
string
number
Boolean
DOM NodeList
JavaScript object
648
8.
,
JavaScript, JavaScript
, JavaScript.
, JavaScript
,
. ,
, , ;
my:func(@value) my:func(string(@value)).
XSLT XPath
, Java,
.
XSLTContext.
XSLTContext :
contextNode
Node
XPath (,
.).
contextPosition
position()).
XPath
contextSize
XPath ( last()).
currentNode
Node
XSLT (,
current()).
ownerDocument
Document
DOM Document,
.
, .
XSLTContext :
systemProperty
XSLT system
property()
stringValue
Node node
XPath
649
JavaScript
XPath ,
DOM, . 634.
:
JavaScript
XPath
string
number
boolean
,
XML , ASCII NUL (#x00); XSLT
. ,
DOM.
XPath,
null. ,
.
functionavailable()
Java
Script, functionavailable() ,
<xsl:script>
, ,
, .
XSLT.
,
XSLT XPath.
, , ,
XSLT 1.1 Recommen
dation,
650
8.
, Java JavaScript.
, XSLT
. ,
,
,
XSLT 1.0. XSLT 1.1,
. , , ,
,
1.0, ,
.
.
,
, ,
XSLT, , , .
, XSLT
.
9
(design patterns) XSLT.
(Erich Gam
ma), (Richard Helm), (Ralph John
son) (John Vlissides) Design
Patterns: Elements of Reusable ObjectOriented Software, Addison Wesley,
ISBN 0201633612 ( :
, , ISBN 5272003551).
, .
23
, ,
, ,
, ,
.
XSLT,
:
,
, ,
, ,
,
. ,
, ,
,
.
652
9.
,
.
,
, , ,
.
HTML.
HTML,
,
HTML.
XSLT , XSLT
,
, ,
HTML.
.
(
, ),
<xsl:stylesheet> <xsl:template match="/"> .
:
XML, orgchart.xml,
,
. ,
:
<orgchart ="28 2001">
<>
<> </>
<> </>
<>
<>
<> </>
<> </>
<>
<>
<> </>
<> </>
</>
<>
<> </>
<> </>
</>
653
</>
</>
<>
<> </>
<> </>
</>
<>
<> </>
<> </>
</>
<>
<> </>
<> </>
</>
<>
<> </>
<> </>
</>
</>
</>
</orgchart>
.
, SVG,
Windows, JavaScript ,
.
HTML, (orgchart.xsl)
:
, , :
<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsl:version="1.0">
<head>
<title> </title>
</head>
<body>
<h1> </h1>
<p> <xsl:valueof select="/orgchart/@"/>
:
</p>
<table border="2" cellpadding="5">
<tr>
<th></th><th></th><th></th>
</tr>
<xsl:foreach select="//">
<tr>
<td><xsl:valueof select=""/></td>
<td><xsl:valueof select=""/></td>
654
9.
<td><xsl:valueof select="ancestor::[1]/"/></td>
</tr>
</xsl:foreach>
</table>
<hr/>
</body>
</html>
,
, .
,
<xsl:valueof>,
. ,
, <xsl:for
each>, <xsl:if> <xsl:choose>.
. 9.1.
XSLT,
,
. ,
XSLT HTML,
. ,
655
, ,
.
, , : XML.
,
.
, XSLT;
XML
. XSLT
DOM, SAX,
, ,
. , do
cument() ( 7) URI
. , Oracle
XSQL XSQL, ,
XML/XSLT/SQL, :
, B.
.
,
, , . , ,
, ,
, , .
HTML,
, ( )
, .
XML, ,
.
:
, , .xml, :
<>
<>
656
9.
<> </>
<> </>
<>HarperCollins</>
<isbn>0 00 649840 X</isbn>
<>6.99</>
<>235</>
</>
<>
<> </>
<> </>
<>Penguin Books</>
<isbn>0 14 018967 X</isbn>
<>12.99</>
<>12</>
</>
</>
(.xsl)
.
$.
, <>
, .
, , ,
.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="" match="" use=""/>
<xsl:variable name=""
select="//[not(.=preceding::)]"/>
<xsl:template match="/">
<html>
<head>
<title> </title>
</head>
<body>
<h1> </h1>
<table>
<tr>
<th></th><th> </th>
</tr>
<xsl:foreach select="$">
<tr>
<td><xsl:valueof select="."/></td>
<td><xsl:calltemplate name=""/></td>
</tr>
657
</xsl:foreach>
</table>
</body>
</html>
</xsl:template>
<! >
<xsl:template name="">
<xsl:valueof select="sum(key('',string(.))/)"/>
</xsl:template>
</xsl:stylesheet>
.
, <xsl:key> ,
<xsl:stylesheet>.
<html>
<head>
<META httpequiv="ContentType" content="text/html; charset=utf8">
<title> </title>
</head>
<body>
<h1> </h1>
<table>
<tr>
<th></th>
<th> </th>
</tr>
<tr>
<td>HarperCollins</td>
<td>235</td>
</tr>
<tr>
<td>Penguin Books</td>
<td>12</td>
</tr>
</table>
</body>
</html>
, <xsl:stylesheet>
<xsl:template> ,
, <xsl:key> <xsl:variable>.
, , XSLT,
HTML
. , ,
,
658
9.
, ,
.
,
<xsl:if>, <xsl:calltemplate> <xsl:foreach>,
, ,
XSLT . ,
, :
,
. ,
, <xsl:foreach>
; XSLT
, ,
.
, .
, ,
, ,
.
,
, , ,
, , , ,
, :
<>, .
,
XSLT, .
,
, .
, ,
,
.
, .
, ,
.
, ,
,
.
,
, ,
23 2000 .,
.
659
, ,
CSS CSS2. CSS , , :
. XSLT
: ,
, , ,
, ,
, .
, ,
.
, HTML,
, <xsl:applytemplates>
. ,
.
: ,
scene2.xml ;
I, 2. :
<?xml version="1.0" encoding="utf8" ?>
<SCENE>
<TITLE> II. .</TITLE>
<STAGEDIR> . .
, .</STAGEDIR>
<SPEECH>
<SPEAKER></SPEAKER>
<LINE> ,</LINE>
<LINE> .</LINE>
<LINE> . </LINE>
<LINE> . </LINE>
<LINE> .</LINE>
</SPEECH>
<SPEECH>
<SPEAKER></SPEAKER>
<LINE> , .</LINE>
</SPEECH>
</SCENE>
,
:
<SCENE>;
<PROLOGUE> <EPILOGUE>. <STAGEDIR>
, ,
,
.
660
9.
.
<SPEECH>
<SPEAKER>. , <SPEECH>
<SPEAKER>,
<LINE> <STAGEDIR> .
scene.xsl .
(
) :
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:variable name="" select="'#FFFFFF'" />
<xsl:template match="SCENE|PROLOGUE|EPILOGUE">
<HTML>
<HEAD>
<TITLE><xsl:valueof select="TITLE"/></TITLE>
</HEAD>
<BODY BGCOLOR='{$}'>
<xsl:applytemplates/>
</BODY>
</HTML>
</xsl:template>
<xsl:valueof>, ,
, ,
.
<SPEECH> ,
:
, :
<xsl:template match="SPEECH">
<TABLE><TR>
<TD WIDTH="160" VALIGN="TOP">
<xsl:applytemplates select="SPEAKER"/>
</TD>
<TD VALIGN="TOP">
<xsl:applytemplates select="STAGEDIR|LINE"/>
</TD>
</TR></TABLE>
</xsl:template>
.
, HTML
. , (<STA
661
GEDIR> <SUBHEAD>,
) HTML ,
,
.
<xsl:template match="TITLE">
<H1><CENTER>
<xsl:applytemplates/>
</CENTER></H1><HR/>
</xsl:template>
<xsl:template match="SPEAKER">
<B>
<xsl:applytemplates/>
<xsl:if test="not(position()=last())"><BR/></xsl:if>
</B>
</xsl:template>
<xsl:template match="SCENE/STAGEDIR">
<CENTER><H3>
<xsl:applytemplates/>
</H3></CENTER>
</xsl:template>
<xsl:template match="SPEECH/STAGEDIR">
<P><I>
<xsl:applytemplates/>
</I></P>
</xsl:template>
<xsl:template match="LINE/STAGEDIR">
[ <I>
<xsl:applytemplates/>
</I> ]
</xsl:template>
<xsl:template match="SCENE/SUBHEAD">
<CENTER><H3>
<xsl:applytemplates/>
</H3></CENTER>
</xsl:template>
<xsl:template match="SPEECH/SUBHEAD">
<P><B>
<xsl:applytemplates/>
</B></P>
</xsl:template>
<xsl:template match="LINE">
<xsl:applytemplates/>
<BR/>
</xsl:template>
</xsl:stylesheet>
662
9.
. 9.2.
, ,
, , ,
,
.
, .
,
. ,
, ,
,
, .
, ,
,
, . ,
, ,
(
).
,
, .
, ,
.
663
. ,
,
.
. :
,
.
<>,
,
<h1> ,
<h1>.
,
,
,
, ,
, .
, , XSLT ,
.
, .
1968 (Edsger
Dijkstra) GoTo
(GoTo Statement Considered Harmful). ,
goto,
. Fortran Co
bol,
,
: if goto .
, ,
.
, ,
ifthenelse whiledo goto,
,
. ,
,
: , goto?.
664
9.
, , , goto .
, Java, goto,
.
,
, . ,
,
.
.
Lisp (
Lots of Irritating Superfluous Parentheses),
ML Scheme. (., ,
(Brian Harvey and Matthew Wright) Simply Scheme: Introducing Com
puter Science, MIT Press, 1999, ISBN 0262082810.)
XSLT ,
,
.
,
, ;
.
XSLT ,
. , ,
, Fortran Co
bol goto,
, C Visual Ba
sic, Java,
.
, XSLT?
,
.
,
,
. goto
jump ,
store,
,
,
.
,
, ,
,
.
665
.
XSLT ;
. ,
, :
O=S(I), I , S
O .
1995 , 1:
DSSSL , SGML
.
XSLT
. ( , DSSSL
XSL.)
.
, Fortran Visual Basic,
, ,
, ,
.
3 9, : 3=sqrt(9). ,
, , ,
. :
9, ? :
, , .
, (pure function),
, ,
, ;
, .
,
,
.
, ,
.
.
.
.
, . x = x+1;
, .
:
temp = x;
x = y;
y = temp;
666
9.
, ,
. ,
:
.
,
, ,
? , ,
, get()
set(). ,
,
,
. ;
, , .
,
( ,
),
, (
). :
,
,
. ,
,
,
. , ,
O=S(I), , ,
, .
, ,
XML,
, ,
, . , XSLT
, ,
, ,
,
,
,
.
XSLT.
, ,
.
, .
( )
. ,
,
667
.
,
, ,
. , ,
, ,
. , ,
, .
, ,
,
:
.
, , .
, XSLT:
.
.
XSLT 1.0 :
, , (
).
, ,
(
).
XSLT 1.1 ,
.
, ,
. XSLT 1.0
, XSLT 1.1
,
.
?
XSLT, , , .
,
,
.
,
, ? ,
: ,
.
= , ,
, , :
. ,
668
9.
, ,
.
,
.
.
XSLT
,
, ,
.
Saxon <saxon:as
sign>, .
, , ,
, ,
,
. :
(a) , XSLT
, .
(b) ,
,
.
(c) , ,
( ),
, .
. XSLT
,
. ,
,
, . ,
, .
PEEK POKE Basic,
,
. ,
,
, .
,
, ,
.
669
, .
. :
int x;
if (zeroBased) {
x=0;
} else {
x=1;
}
XSLT ?
:
int x = (zeroBased ? 0 : 1 );
XSLT :
<xsl:variable name="x">
<xsl:choose>
<xsl:when test="$zeroBased">0</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
,
<xsl:variable>, select,
. ,
, , ,
,
.
, $
, $
. :
<xsl:variable name=""
select="//[$] | //[not($)]"/>
, .
|.
$ , [$]
, [not($)] ,
//;
$ , ,
//.
670
9.
,
.
for Ite
rator Enumerator , :
, , .
,
.
.
:
iterator = list.getIterator();
while (iterator.hasMoreItems()) {
item = iterator.getNextItem();
item.doSomething();
}
,
, item = iterator.getNextItem().
item, , iterator,
,
.
,
. :
function () {
if (!()) {
(());
(());
}
}
.
,
. ( ,
() , () ,
, ).
, , , ,
.
, .
.
,
. XSLT
, XSLT
671
, <xsl:applytemplates> <xsl:foreach>,
,
, sum() count()
;
, .
?
, . ,
() , ,
,
, .
,
.
:
, ,
, "12 34.5 18.2 35",
. ( ; XML,
, .)
, .xml :
<>12 34.5 18.2 35</>
, XPath. 7.
:
normalizespace(),
.
concat(), .
, ,
.
substringbefore(),
.
substringafter(),
, .
number(), .
,
.
672
9.
( .xsl):
<xsl:template name="">
<xsl:param name=""/>
<xsl:variable name=""
select="concat(normalizespace($), ' ')"/>
<xsl:choose>
<xsl:when test="$!=' '">
<xsl:variable name=""
select="substringbefore($, ' ')"/>
<xsl:variable name=""
select="substringafter($, ' ')"/>
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="$"/>
</xsl:calltemplate>
</xsl:variable>
<xsl:valueof select="number($) + number($)"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:template>
, ,
.
,
, .
normalizespace(),
;
concat()
,
, . (
, ,
.
, ,
.)
, .
<xsl:when> (
, ,
). <xsl:otherwise>,
, .
$ sub
stringbefore() ,
$ substringafter()
.
. <xsl:withparam>
,
673
,
. <xsl:valueof>
, .
:
<xsl:template match="/">
<xsl:calltemplate name="">
<xsl:withparam name="" select="."/>
</xsl:calltemplate>
</xsl:template>
29.7
<xsl:calltemplate> 4.
,
. XPath
, :
.
:
,
. 655.
,
sum(), XSLT.
.xml,
. :
<>
<>
<> </>
<> </>
<>HarperCollins</>
<isbn>0 00 649840 X</isbn>
<>6.99</>
<>235</>
</>
<>
<> </>
<> </>
<>Penguin Books</>
<isbn>0 14 018967 X</isbn>
<>12.99</>
<>12</>
674
9.
</>
</>
.xsl.
, .
<>, .
, , .
,
,
,
.
, ,
XPath: , [1]
[position()!=1] .
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template name="">
<xsl:param name=""/>
<xsl:choose>
<xsl:when test="$">
<xsl:variable name="" select="$[1]"/>
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="$[position()!=1]"/>
</xsl:calltemplate>
</xsl:variable>
<xsl:valueof select="$/ * $/ + $"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:template>
, formatnumber(),
7.
<xsl:template match="/">
<xsl:variable name="">
<xsl:calltemplate name="">
<xsl:withparam name="" select="//"/>
</xsl:calltemplate>
</xsl:variable>
: <xsl:valueof select="formatnumber($, '$#.00')"/>
</xsl:template>
</xsl:stylesheet>
675
: $1798.53
:
. , ,
,
. ,
.
, XSLT 1.0
,
, .
, XSLT 1.0
:
. ,
,
.
XSLT 1.1 ,
,
. ,
XSLT 1.0 ,
, MSXML3 msxml:nodeset(),
.
, :
,
,
XSLT .
, 10,
.
,
, . ,
, . ,
,
.
,
.
,
676
9.
, $100000 .
XSLT . ,
, ,
( ),
. .
, ,
.
.
,
, .
, :
,
,
.
, ,
, . XSLT 1.0
: ,
. XSLT 1.1 (
XSLT 1.0, nodeset())
, .
,
XPath. , ,
, ,
: <min> <max>,
. , ,
minimax.xsl;
.
<xsl:template name="getminandmax">
<xsl:param name="nodes"/>
<xsl:param name="bestsofar">
<min><xsl:valueof select="999999999"/></min>
<max><xsl:valueof select="999999999"/></max>
</xsl:param>
<xsl:choose>
<xsl:when test="$nodes">
<xsl:variable name="newbestsofar">
<min>
<xsl:choose>
<xsl:when test="$nodes[1] < $bestsofar/min">
<xsl:valueof select="$nodes[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:valueof select="$bestsofar/min"/>
</xsl:otherwise>
</xsl:choose>
677
</min>
<max>
<xsl:choose>
<xsl:when test="$nodes[1] > $bestsofar/max">
<xsl:valueof select="$nodes[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:valueof select="$bestsofar/max"/>
</xsl:otherwise>
</xsl:choose>
</max>
</xsl:variable>
<xsl:calltemplate name="getminandmax">
<xsl:withparam name="nodes" select="$nodes[position() > 1]"/>
<xsl:withparam name="bestsofar" select="$newbestsofar"/>
</xsl:calltemplate>
</xsl:when>
<xsl:otherwise>
<xsl:copyof select="$bestsofar"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
, $bestso
far, :
<xsl:variable name="minandmax">
<xsl:calltemplate name="getminandmax">
<xsl:withparam name="nodes" select="//item/"/>
</xsl:calltemplate>
</xsl:variable>
Minimum price is: <xsl:valueof select="$minandmax/min"/>.
Maximum price is: <xsl:valueof select="$minandmax/max"/>.
,
,
,
.
, .
:
,
. XSLT
:
,
. <xsl:foreach> <xsl:applytemplates>,
.
;
XSLT 1.1 XSLT 1.0
nodeset().
678
9.
( ) :
,
,
. ,
TrAX, F.
,
XSLT .
,
, .
,
:
<>
< ="" =""/>
. .
</>
, :
<>
< ="">
<>1</>
<>2</>
</>
. .
</>
, , ,
:
= .("");
= null;
("<>")
{
= .("");
if ( != ) {
("</>\n<>");
}
("<>" + .("") + "</>");
= ;
}
("</>")
XSLT , , . ,
, , :
,
. ,
679
.
XSLT
, ,
. .
:
.xml.
, :
<>
<
<
<
<
<
<
<
<
<
</>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
="" =""/>
( ,
) .
.xsl:
<xsl:template match="/">
<xsl:variable name=""
select="/
/[not(@=precedingsibling::/@)]
/@"
/>
<> ,
, ,
. ,
. :
, ,
: precedingsibling:: precedingsibling::[1].
,
.
.
680
9.
<> ,
preceding, precedingsibling.
.
,
<>:
<xsl:template match="/">
<xsl:variable name=""
select="/
/[not(@=precedingsibling::/@)]
/@"
/>
<>
<xsl:foreach select="$">
< name="{.}">
<xsl:foreach select="//[@=current()]">
<><xsl:valueof select="@"/></>
</xsl:foreach>
</>
</xsl:foreach>
</>
</xsl:template>
<>
< ="">
<></>
<></>
<></>
</>
< ="">
<></>
<></>
<></>
<></>
</>
< ="">
<></>
<></>
</>
</>
,
N ,
, N (N 1) / 2 .
. ,
, ,
681
. , XSLT
, . XSLT
,
.
,
.
, .
, :
,
, .
.xsl, . XSLT 1.1,
$
.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:variable name="">
<xsl:foreach select="//">
<xsl:sort select="@"/>
<xsl:copyof select="."/>
</xsl:foreach>
</xsl:variable>
<xsl:variable name=""
select="$
/[not(@=precedingsibling::[1]/@)]
/@"
/>
<>
<xsl:foreach select="$">
< name="{.}">
<xsl:foreach select="$/[@=current()]"
>
<><xsl:valueof select="@"/></>
</xsl:foreach>
</>
</xsl:foreach>
</>
</xsl:template>
</xsl:stylesheet>
, XSLT
, , preceding
682
9.
sibling::[1],
,
, 1 position() .
, XSLT
.
, ,
, ,
.
, .
, (Steve
Muench) Oracle, . .
, .
:
, , .xml.
.xsl.
, ,
:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<xsl:key name="" match="" use="@"/>
, <>, @
, key('
', '').
, key('', '')[1]
.
, ,
(
):
generateid(.)=generateid(key('', @)[1])
683
[1] ,
generateid() .
:
count(. | key('', @)[1]) = 1
[not(@=precedingsibling::/@)],
,
. , :
<xsl:key name="" match="" use="@"/>
<xsl:template match="/">
<xsl:variable name=""
select="/
/[generateid(.)=
generateid(key('', @))]
/@"
/>
<>
<xsl:foreach select="$">
< name="{.}">
<xsl:foreach select="key('', .)">
<><xsl:valueof select="@"/></>
</xsl:foreach>
</>
</xsl:foreach>
</>
</xsl:template>
, .
,
precedingsibling ,
,
,
. ,
,
( , ,
) ,
.
, . ,
,
, :
<key name="alphagroup" match="" use="substring(@, 1, 1)"/>
684
9.
XSLT, :
.
,
.
W3C, ,
, ,
, , , .
, ,
XSLT 2.0,
http://www.w3.org/TR/XSLT20req. ,
<saxon:group>,
Saxon, XSLT
Unicorn. Saxon
:
<>
<saxon:group select="//" groupby="@">
<xsl:sort select="@"/>
< name="{@}">
<saxon:item>
<><xsl:valueof select="@"/></>
</saxon:item>
</>
</saxon:group>
</>
. C.
XSLT:
, ,
, XSLT
,
.
.
10
,
XSLT ,
XML.
.
,
Wrox http://www.wrox.com/.
, XSLT
,
. :
, ,
W3C, XML XSLT.
, ,
9.
.
, ,
. ,
.
, .
, XSLT
, ,
,
. XSLT ,
, , XSLT
,
,
.
686
10.
XML
,
XML. W3C
XML, XSLT XPath
XML, HTML.
XML XML HTML, :
. 10.1. XML.
, XSLT XPath,
XML,
.
(Ed
uardo Gutentag), (James
Clark). ,
.
,
,
XSLT, ;
. http://www.wrox.com/
.
,
, 9.
XML
,
.
XML
687
XML. http://
www.w3.org/TR/1998/RECxml19980210.xml,
. , XML,
XML. ,
, ,
. :
<!ENTITY lt "<">,
, ,
. IE5
. ,
SGML.
, DTD ( spec.dtd)
,
.
DTD. XML
, ,
.
, ,
.
DTD;
. RECXML19980210.XML, DTD
spec.dtd.
IE5 XML.
XML XSLT XPath ,
W3C, IE5,
Wrox.
, IE5
, XML .
View Source,
XML .
xmlspec.xsl.
:
<?xml version="1.0" encoding="ISO88591" ?>
<! 1999/01/11 SMI; Style Sheet for the XML and XSL
Recommendations and Working Drafts;
written by Eduardo Gutentag >
<! v 1.28 1999/11/15 12:58:16 by James Clark >
<!DOCTYPE xsl:stylesheet [
<!ENTITY copy "©">
688
10.
<!ENTITY nbsp
]>
" ">
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
doctypepublic="//W3C//DTD HTML 4.0 Transitional//EN"/>
<xsl:param name="w3">http://www.w3.org/</xsl:param>
XML,
XML; iso88591,
, UTF8.
ASCII,
UTF8 .
,
.
<!DOCTYPE> DTD;
, DTD
. <!DOCTYPE>
.
©, .
, ©
 , .
,
, ,
HTML. , XSLT ,
, ,
.
<xsl:stylesheet> . <xsl:output>
html
HTML,
. . , , ,
W3C HTML,
.
<xsl:param> , w3,
, URL W3C.
,
, ,
URL, .
HTML
.
, ,
XML
689
. ,
.
<xsl:template match="spec">
<html>
<head>
<title>
<xsl:valueof select="header/title"/>
</title>
<link rel="stylesheet" type="text/css"
href="{$w3}StyleSheets/TR/W3C{
substringbefore(header/w3cdesignation,'')}"/>
<! This stops Netscape 4.5 from messing up. >
<style type="text/css">
<xsl:applytemplates select="." mode="css"/>
</style>
</head>
<body>
<xsl:applytemplates/>
</body>
</html>
</xsl:template>
, HTML.
, ,
, ,
,
<spec>.
HTML, :
, CSS,
( ,
), HTML <body>
<xsl:applytemplates>, <spec>
.
<xsl:applytemplates mode="css"/>
,
<style>. ,
<xsl:calltemplate>
. , :
,
, . ,
XSLT,
, .
<xsl:template match="spec" mode="css">
<xsl:text>code { fontfamily: monospace }</xsl:text>
</xsl:template>
690
10.
HTML <title>,
<header> XML.
<header>
. XML
:
<spec>
<header>
<title>Extensible Markup Language (XML) 1.0</title>
<version></version>
<w3cdesignation>RECxml&iso6.doc.date;</w3cdesignation>
<w3cdoctype>W3C Recommendation</w3cdoctype>
<pubdate>
<day>&draft.day;</day>
<month>&draft.month;</month>
<year>&draft.year;</year>
</pubdate>
<publoc>
<loc href="url">url</loc>
<loc href="url">url</loc>
</publoc>
<latestloc>
<loc href="url">url</loc>
</latestloc>
<prevlocs>
<loc href="url">url</loc>
</prevlocs>
<authlist>
<author>
<name>Tim Bray</name>
<affiliation>Textuality and Netscape</affiliation>
<email href="mailto:tbray@textuality.com">
tbray@textuality.com</email>
</author>
</authlist>
<abstract>
<p>The Extensible Markup Language (XML) is a subset of SGML
that is completely described in this document...</p>
</abstract>
<status>
<p>This document has been reviewed by W3C Members and
other interested parties ...</p>
<p>This document specifies a syntax It is a product of the W3C
XML Activity, details of which can be found at <loc
href='url'>url</loc>. A list of current W3C
XML
691
</back>
</spec>
,
, , <loc>,
, .
:
<xsl:template match="header">
<div class="head">
<! W3C >
<a href="http://www.w3.org/">
<img src="{$w3}Icons/WWW/w3c_home"
alt="W3C" height="48" width="72"/>
</a>
<! >
<h1><xsl:valueof select="title"/><br/>
<xsl:valueof select="version"/>
</h1>
<! >
<h2>
<xsl:valueof select="w3cdoctype"/>
<xsl:text> </xsl:text>
<xsl:valueof select="pubdate/day"/>
<xsl:text> </xsl:text>
<xsl:valueof select="pubdate/month"/>
<xsl:text> </xsl:text>
<xsl:valueof select="pubdate/year"/>
</h2>
<! URL >
<dl>
<xsl:applytemplates select="publoc"/>
692
10.
<xsl:applytemplates select="latestloc"/>
<xsl:applytemplates select="prevlocs"/>
<xsl:applytemplates select="authlist"/>
</dl>
<! >
<xsl:calltemplate name="copyright"/>
<hr title="Separator for header"/>
</div>
<! >
<xsl:applytemplates select="abstract"/>
<xsl:applytemplates select="status"/>
</xsl:template>
<! >
<xsl:template match="publoc">
<dt>This version:</dt>
<dd><xsl:applytemplates/></dd>
</xsl:template>
<xsl:template match="latestloc">
<dt>Latest version:</dt>
<dd><xsl:applytemplates/></dd>
</xsl:template>
<xsl:template match="prevlocs">
<dt>
<xsl:text>Previous version</xsl:text>
<xsl:if test="count(loc)>1">s</xsl:if>
<xsl:text>:</xsl:text>
</dt>
<dd><xsl:applytemplates/></dd>
</xsl:template>
<xsl:template match="publoc/loc | latestloc/loc | prevlocs/loc">
<a href="{@href}"><xsl:applytemplates/></a>
<br/>
</xsl:template>
<!
>
<xsl:template match="authlist">
<dt>
<xsl:text>Editor</xsl:text>
<xsl:if test="count(author)>1">s</xsl:if>
<xsl:text>:</xsl:text>
</dt>
<dd><xsl:applytemplates/></dd>
</xsl:template>
<xsl:template match="author">
<xsl:applytemplates/><br/>
XML
693
</xsl:template>
<xsl:template match="author/name">
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="author/affiliation">
<xsl:text> (</xsl:text>
<xsl:applytemplates/>
<xsl:text>) </xsl:text>
</xsl:template>
<xsl:template match="author/email">
<a href="{@href}">
<xsl:text><</xsl:text>
<xsl:applytemplates/>
<xsl:text>></xsl:text>
</a>
</xsl:template>
<! >
<xsl:template match="abstract">
<h2><a name="abstract">Abstract</a></h2>
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="status">
<h2><a name="status">Status of this document</a></h2>
<xsl:applytemplates/>
</xsl:template>
. ,
(previous versions) (editors),
<xsl:text>,
.
,
(back), .
<back> , .
<xsl:template match="body">
<h2><a name="contents">Table of contents</a></h2>
<xsl:calltemplate name="toc"/>
<hr/>
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="back">
<hr title="Separator from footer"/>
<xsl:applytemplates/>
</xsl:template>
694
10.
<body> :
,
<xsl:applytemplates> .
, . <body>,
<back> <div1>,
:
<div1>
<head>Firstlevel heading</head>
<p>Some text</p>
<div2>
<head>Secondlevel heading</head>
<p>Some more text</p>
<div3>
<head>Thirdlevel heading</head>
<p>Lots more text</p>
</div3>
</div2>
</div1>
<div1> <head>,
,
<div2>, . <div2>
<head> <div3>
, .
<back> <in
formdiv1> <div1>, .
,
, .
.
<body>,
<back>.
, makeref:
<xsl:template name="toc">
<xsl:foreach select="/spec/body/div1">
<xsl:calltemplate name="makeref"/><br/>
<xsl:foreach select="div2">
<xsl:text> </xsl:text>
<xsl:calltemplate name="makeref"/><br/>
<xsl:foreach select="div3">
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
<xsl:calltemplate name="makeref"/><br/>
</xsl:foreach>
</xsl:foreach>
</xsl:foreach>
XML
695
<h3>Appendices</h3>
<xsl:foreach select="/spec/back/div1 | /spec/back/informdiv1">
<xsl:calltemplate name="makeref"/><br/>
<xsl:foreach select="div2">
<xsl:text> </xsl:text>
<xsl:calltemplate name="makeref"/><br/>
<xsl:foreach select="div3">
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
<xsl:calltemplate name="makeref"/><br/>
</xsl:foreach>
</xsl:foreach>
</xsl:foreach>
</xsl:template>
<xsl:template name="makeref">
<xsl:applytemplates select="." mode="number"/>
<xsl:choose>
<xsl:when test="@id">
<a href="#{@id}">
<xsl:valueof select="head"/>
</a>
</xsl:when>
<xsl:otherwise>
<a href="#section{translate(head,' ','')}">
<xsl:valueof select="head"/>
</a>
</xsl:otherwise>
</xsl:choose>
<xsl:foreach select="head">
<xsl:calltemplate name="inform"/>
</xsl:foreach>
</xsl:template>
<xsl:template name="inform">
<xsl:if test="parent::informdiv1">
<xsl:text> (NonNormative)</xsl:text>
</xsl:if>
</xsl:template>
makeref ,
, id , ,
, (
). ,
, Example, id
: , generateid(),
. , (
<informdiv1>), (NonNormative).
, , , . ,
inform
,
696
10.
. make
ref <xsl:if self::informdiv1>.
makeref
, , .
,
.
: , .
,
,
.
<xsl:template mode="number" match="*">
<xsl:number
level="multiple"
count="informdiv1 | div1 | div2 | div3 | div4"
format="1.1 "/>
</xsl:template>
<xsl:template mode="number" match="back//*">
<xsl:number
level="multiple"
count="informdiv1 | div1 | div2 | div3 | div4"
format="A.1 "/>
</xsl:template>
count
.
, <informdiv1>, <div1>, <div2>, . .
,
, :
, ,
.
,
:
?
.
(<a name="xyz">...</a>)
,
. id, ;
.
,
.
, .
XML
697
<xsl:foreach select="..">.
( ),
, <head>
<divX>, , ,
insertID.
inform head, ,
(Nonnormative).
. ,
. ,
, XML: ,
.
698
10.
<p>
! DTD XML,
, , HTML,
.
HTML
. ,
W3C,
. .
<xsl:template match="term">
<b><xsl:applytemplates/></b>
</xsl:template>
<xsl:template match="code">
<code><xsl:applytemplates/></code>
</xsl:template>
<xsl:template match="emph">
<i><xsl:applytemplates/></i>
</xsl:template>
<xsl:template match="blist">
<dl><xsl:applytemplates/></dl>
</xsl:template>
<xsl:template match="slist">
<ul><xsl:applytemplates/></ul>
</xsl:template>
<xsl:template match="sitem">
<li><xsl:applytemplates/></li>
</xsl:template>
<xsl:template match="olist">
<ol><xsl:applytemplates/></ol>
</xsl:template>
<xsl:template match="ulist">
<ul><xsl:applytemplates/></ul>
</xsl:template>
<xsl:template match="glist">
<dl><xsl:applytemplates/></dl>
</xsl:template>
XML
699
<xsl:template match="olist">
<ol><xsl:applytemplates/></ol>
</xsl:template>
<xsl:template match="item">
<li><xsl:applytemplates/></li>
</xsl:template>
<xsl:template match="label">
<dt><b><xsl:applytemplates/></b></dt>
</xsl:template>
<xsl:template match="def">
<dd><xsl:applytemplates/></dd>
</xsl:template>
<xsl:template match="quote">
<xsl:text>"</xsl:text>
<xsl:applytemplates/>
<xsl:text>"</xsl:text>
</xsl:template>
<! >
<xsl:template match="eg">
<pre>
<xsl:if test="@role='error'">
<xsl:attribute name="style">color: red</xsl:attribute>
</xsl:if>
<xsl:applytemplates/>
</pre>
</xsl:template>
<! >
<xsl:template match="htable">
<table border="{@border}"
cellpadding="{@cellpadding}"
align="{@align}">
<xsl:applytemplates/>
</table>
</xsl:template>
, border="{@border}" border="",
border.
:
<table>
<xsl:copyof select="@align | @border | @cellpadding"/>
<xsl:applytemplates/>
</table>
:
<xsl:template match="htbody">
<tbody><xsl:applytemplates/></tbody>
700
10.
</xsl:template>
<xsl:template match="tr">
<tr align="{@align}" valign="{@valign}">
<xsl:applytemplates/>
</tr>
</xsl:template>
<xsl:template match="td">
<td bgcolor="{@bgcolor}"
rowspan="{@rowspan}" colspan="{@colspan}"
align="{@align}" valign="{@valign}">
<xsl:applytemplates/>
</td>
</xsl:template>
<! >
<xsl:template match="ednote">
<blockquote>
<p><b>Ed. Note: </b><xsl:applytemplates/></p>
</blockquote>
</xsl:template>
<xsl:template match="edtext">
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="issue">
<xsl:calltemplate name="insertID"/>
<blockquote>
<p><b>Issue (<xsl:text/>
<xsl:valueof select="substringafter(@id,'')"/>
<xsl:text/>): </b>
<xsl:applytemplates/>
</p>
</blockquote>
</xsl:template>
<xsl:template match="note">
<blockquote>
<b>NOTE: </b><xsl:applytemplates/>
</blockquote>
</xsl:template>
<xsl:template match="issue/p | note/p">
<xsl:applytemplates/>
</xsl:template>
. XML
, .
<scrap>, <prod>.
XML
701
<scrap>,
:
<scrap lang='ebnf' id='document'>
<head>Document</head>
<prod id='NTdocument'>
<lhs>document</lhs>
<rhs>
<nt def='NTprolog'>prolog</nt>
<nt def='NTelement'>element</nt>
<nt def='NTMisc'>Misc</nt>*
</rhs>
</prod>
</scrap>
, , XML,
:
Document
[1] document ::= prolog element Misc*
<scrap>
<prodgroup>,
.
:
<xsl:template match="scrap">
<xsl:if test="string(head)">
<h5><xsl:valueof select="head"/></h5>
</xsl:if>
<table class="scrap">
<tbody>
<xsl:applytemplates select="prodgroup | prod"/>
</tbody>
</table>
</xsl:template>
<xsl:template match="prodgroup">
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="prod">
<! , >
<xsl:applytemplates
select="*[self::lhs
or (self::rhs
and not(precedingsibling::*[1][self::lhs]))
or ((self::vc or self::wfc or self::com)
and not(precedingsibling::*[1][self::rhs]))]
"/>
</xsl:template>
702
10.
select? (<prod>)
(<lhs>), (<rhs>)
(<vc>, <wfc> <com>). <vc>
, <wfc>
<com> .
<lhs>, <rhs>
<wfc> HTML :
[17]
lhs1
::=
rhs1
rhs2
wfc1
wfc2
wfc3
, select
<prod>, :
lhs1, rhs2, wfc2 wfc3. ,
<lhs>, <rhs>,
<lhs>, <vc>, <wfc> <com>,
<rhs>. ,
, ,
<xsl:applytemplates> .
,
. <lhs>:
<xsl:template match="lhs">
<tr valign="baseline">
<td><a name="{../@id}"/>
<xsl:number from="body" level="any"
format="[1] "/>
</td>
<td><xsl:applytemplates/></td>
<td>
<xsl:text> ::= </xsl:text>
</td>
<xsl:foreach select="followingsibling::*[1]">
<td><xsl:applytemplates mode="cell" select="."/></td>
<td><xsl:applytemplates mode="cell"
select="followingsibling::*[1]
[self::vc or self::wfc or self::com]"/>
</td>
</xsl:foreach>
</tr>
</xsl:template>
<xsl:number> ,
.
<lhs>,
.
XML
703
<xsl:applytemplates/>
<lhs>,
, ::= ,
.
<xsl:foreach> ,
. , select [1]
.
<rhs>.
<xsl:applytemplates> mode="cell"; ,
<vc>, <wfc> <com>,
mode="cell". ,
,
: ,
<lhs>.
, ,
<rhs>, , <vc>, <wfc>
<com>, : rhs2, wfc2
wfc3 .
.
<xsl:template match="rhs">
<tr valign="baseline">
<td></td>
<td></td>
<td></td>
<td><xsl:applytemplates mode="cell" select="."/></td>
<td><xsl:applytemplates mode="cell"
select="followingsibling::*[1]
[self::vc or self::wfc or self::com]"/>
</td>
</tr>
</xsl:template>
<xsl:template match="vc | wfc | com">
<tr valign="baseline">
<td></td>
<td></td>
<td></td>
<td></td>
<td><xsl:applytemplates mode="cell" select="."/></td>
</tr>
</xsl:template>
, <td>
</td>, ,
.
704
10.
<rhs> , <lhs>:
<rhs> <vc>, <wfc> <com>,
.
,
, , rhs1 wfc1.
mode="cell".
, <td> .
<xsl:template match="rhs" mode="cell">
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="com" mode="cell">
<xsl:text>/*</xsl:text>
<xsl:applytemplates/>
<xsl:text>*/</xsl:text>
</xsl:template>
<vc> <wfc> ,
, . XML
def,
HTML.
, ID def,
.
, <vc> <vc def="vcroottype"/>,
:
<vcnote id="vcroottype">
<head>Root Element Type</head>
<p>The Name in the document type declaration must match the element type
of the root element.</p>
</vcnote>
HTML:
<a href="#vcroottype">Root Element Type</a>
:
<xsl:template match="vc" mode="cell">
<xsl:text>[ VC: </xsl:text>
<a href="#{@def}">
<xsl:valueof select="id(@def)/head"/>
</a>
<xsl:text> ]</xsl:text>
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="wfc" mode="cell">
<xsl:text>[ WFC: </xsl:text>
<a href="#{@def}">
XML
705
<xsl:valueof select="id(@def)/head"/>
</a>
<xsl:text> ]</xsl:text>
<xsl:applytemplates/>
</xsl:template>
!
, .
.
, ,
<a name="xyz">...</a>.
,
.
<xsl:template match="blist/bibl">
<dt>
<a name="{@id}"><xsl:valueof select="@key"/></a>
</dt>
<dd>
<xsl:applytemplates/>
</dd>
</xsl:template>
<xsl:template match="termdef">
<a name="{@id}"/><xsl:applytemplates/>
</xsl:template>
<xsl:template match="vcnote">
<a name="{@id}"/>
<p><b>Validity Constraint: <xsl:text/>
<xsl:valueof select="head"/></b></p>
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="wfcnote">
<a name="{@id}"></a>
<p><b>Well Formedness Constraint: <xsl:text/>
<xsl:valueof select="head"/></b></p>
<xsl:applytemplates/>
</xsl:template>
, .
<a href="xyz">...</a>
<a href="#xyz">...</a> .
<! >
<xsl:template match="p/loc" priority="1">
<a href="{@href}"><xsl:applytemplates/></a>
</xsl:template>
706
10.
<xsl:template match="loc">
<a href="{@href}"><xsl:applytemplates/></a>
</xsl:template>
priority :
,
. ,
!
, , .
<xsl:template match="xspecref | xtermref">
<a href="{@href}"><xsl:applytemplates/></a>
</xsl:template>
<xsl:template match="xnt">
<a href="{@href}"><xsl:applytemplates/></a>
</xsl:template>
<! >
<xsl:template match="titleref">
<a href="#{@href}"><xsl:applytemplates/>
</xsl:template>
</a>
<xsl:template match="nt">
<a href="#{@def}"><xsl:applytemplates/></a>
</xsl:template>
<xsl:template match="termref">
<a href="#{@def}"><xsl:applytemplates/></a>
</xsl:template>
<xsl:template match="bibref">
<a href="#{@ref}">
<xsl:text>[</xsl:text>
<xsl:valueof select="id(@ref)/@key"/>
<xsl:applytemplates/>
<xsl:text>]</xsl:text>
</a>
</xsl:template>
<xsl:template match="specref">
<a href="#{@ref}">
<xsl:text>[</xsl:text>
<b>
<! >
<xsl:foreach select="id(@ref)/head">
<xsl:applytemplates select=".." mode="number"/>
<xsl:applytemplates/>
</xsl:foreach>
</b>
<xsl:applytemplates/>
<xsl:text>]</xsl:text>
</a>
</xsl:template>
XML
707
. ,
: , ,
, <xsl:applytemplates>,
, , mode="number".
XML
, HTML.
<xsl:template> ,
, , ,
.
,
, .
<xsl:template
<xsl:template
<xsl:template
<xsl:template
<xsl:template
<xsl:template
<xsl:template
<xsl:template
<xsl:template
match="w3cdesignation"/>
match="w3cdoctype"/>
match="header/pubdate"/>
match="spec/header/title"/>
match="revisiondesc"/>
match="pubstmt"/>
match="sourcedesc"/>
match="langusage"/>
match="version"/>
, , ,
, . (
,
. ,
.)
, :
<xsl:template name="copyright">
<xsl:variable name="legal"
select="'http://www.w3.org/Consortium/Legal/'"/>
<p class="copyright">
<a href="{$legal}iprnotice.html#Copyright">Copyright</a>
© 1999
<a href="http://www.w3.org">W3C</a>
(<a href="http://www.lcs.mit.edu">MIT</a>,
<a href="http://www.inria.fr/">INRIA</a>,
<a href="http://www.keio.ac.jp/">Keio</a>),
All Rights Reserved. W3C
<a href="{$legal}iprnotice.html#Legal_Disclaimer"
>liability</a>,
<a href="{$legal}iprnotice.html#W3C_Trademarks"
708
10.
>trademark</a>,
<a href="{$legal}copyrightdocuments.html">document use</a>
and
<a href="{$legal}copyrightsoftware.html"
>software licensing</a> rules apply.
</p>
</xsl:template>
,
. orglist/member
,
, , .
priority ,
.
<xsl:template match="orglist">
<xsl:applytemplates select="*"/>
</xsl:template>
<xsl:template match="orglist/member[1]" priority="2">
<xsl:applytemplates select="*"/>
</xsl:template>
<xsl:template match="orglist/member">
<xsl:text>; </xsl:text>
<xsl:applytemplates select="*"/>
</xsl:template>
<xsl:template match="orglist/member/affiliation">
<xsl:text>, </xsl:text>
<xsl:applytemplates/>
</xsl:template>
<xsl:template match="orglist/member/role">
<xsl:text> (</xsl:text>
<xsl:applytemplates/>
<xsl:text>)</xsl:text>
</xsl:template>
:
</xsl:stylesheet>
XSLT
XPath
XML. , XPath XSLT,
,
, XML.
709
XML DTD,
DTD
. , XPath
, XSLT
,
XSL.
, XPath XSLT,
, <xsl:import>
XML ,
.
.
, , ,
, .
, ,
XSLT,
. , ,
,
.
.
HTML
,
. , ,
.
:
,
, .
XML ,
.
( ,
XML)
.
,
. , ,
, ,
.
, .
XML,
710
10.
, ,
. , ,
.
,
, XML
.
, .
: ,
!
XML
GEDCOM,
, .
, GEDCOM, ,
( INDI),
, ( FAM).
INDI :
0
1
1
1
2
2
1
2
2
2
1
2
2
2
2
1
1
@I1@ INDI
NAME John Fitzgerald/Kennedy/
SEX M
BIRT
DATE 29 MAY 1917
PLAC Brookline, MA, USA
DEAT
DATE 22 NOV 1963
PLAC Dallas, TX, USA
NOTE Assassinated by Lee Harvey Oswald.
NOTE Educated at Harvard University.
CONT Elected Congressman in 1945
CONT aged 29; served three terms in the House of Representatives.
CONT Elected Senator in 1952. Elected President in 1960, the
CONT youngest ever President of the United States.
FAMS @F1@
FAMC @F2@
, , XML, XML,
:
<INDI ID="I1">
<NAME>John Fitzgerald<S>Kennedy</S></NAME>
<SEX>M</SEX>
<BIRT>
<DATE>29 MAY 1917</DATE>
<PLAC>Brookline, MA, USA</PLAC>
</BIRT>
711
<DEAT>
<DATE>22 NOV 1963</DATE>
<PLAC>Dallas, TX, USA</PLAC>
<NOTE>Assassinated by Lee Harvey Oswald.<BR/></NOTE>
</DEAT>
<NOTE>Educated at Harvard University.<BR/>
Elected Congressman in 1945<BR/>
aged 29; served three terms in the House of Representatives.<BR/>
Elected Senator in 1952. Elected President in 1960, the<BR/>
youngest ever President of the United States.<BR/>
</NOTE>
<FAMS REF="F1"/>
<FAMC REF="F2"/>
</INDI>
( . 732) ,
XML.
GEDCOM (
I1 I ),
.
, <FAMS> <FAMC>: <FAMS>
<FAM>, ,
, <FAMC> , .
, ,
. GEDCOM (
Church of Jesus Christ of Latterday Saints)
, DTD XML.
HTML GEDCOM http://www.gen
dex.com/gedcom55/55gcint.htm.
,
. , ,
, ,
.
, ,
; , ;
.
<INDI>
, <FAM>
( , ,
, ; ,
, ). <FAM>,
<INDI>, .
XML :
<FAM ID="F1">
<HUSB REF="I1"/>
<WIFE REF="I2"/>
712
10.
<CHIL REF="I5"/>
<CHIL REF="I6"/>
<CHIL REF="I7"/>
<MARR>
<DATE>12 SEP 1953</DATE>
<PLAC>Newport, RI, USA</PLAC>
</MARR>
</FAM>
<FAM> , .
,
;
. ,
,
.
, ,
.
. 10.2.
,
.
, QWERTY, GEDCOM ,
, , .
GEDCOM .
XML, , ,
713
.
, ( ),
,
.
, ,
XML.
,
GEDCOM HTML. ,
XML ( ,
. 732). ,
. 10.3 .
. 10.3.
,
. ,
, :
, ,
GEDCOM, ,
.
HTML, , HTML
XML. , ,
:
714
10.
, XML
HTML,
. ,
.
, ,
.
HTML Java
ASP. ,
,
ASP.
XML
. ,
,
. ,
XML, Internet Explorer 5 .
Netscape 6 / Mozilla XML CSS, XSLT (
Transformiix) .
http://www.mozilla.org/projects/xslt/.
:
, ,
XML
( , , View So#
urce ).
,
, ,
.
,
, .
,
.
, person.xsl, HTML
, , .
ID
. , <INDI>
. :
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xsl:param name="id" select="/*/INDI[1]/@ID"/>
<! >
715
<INDI> <FAM>,
ID, .
id(), , ID DTD
ID.
DTD ,
key().
( )
<xsl:applytemplates> <INDI>,
.
<INDI> HTML:
<xsl:template match="INDI">
<html>
<head>
<xsl:calltemplate name="cssstyle"/>
<xsl:variable name="name">
<xsl:applytemplates select="NAME"/>
</xsl:variable>
<title><xsl:valueof select="$name"/></title>
</head>
<! >
<xsl:variable name="color">
<xsl:choose>
<xsl:when test="SEX='M'">cyan</xsl:when>
<xsl:otherwise>pink</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<body bgcolor="{$color}">
<! >
<h1><xsl:applytemplates select="NAME"/></h1>
<xsl:calltemplate name="showparents"/>
<hr/>
<table>
<tr>
<! >
<td width="50%" valign="top">
716
10.
<xsl:calltemplate name="showevents"/>
</td>
<td width="20%"/>
<! , >
<td width="30%" valign="top">
<xsl:calltemplate name="showpartners"/>
</td>
</tr>
</table>
<hr/>
<! >
<xsl:foreach select="NOTE">
<p class="text"><xsl:applytemplates/></p>
<xsl:if test="position()=last()"><hr/></xsl:if>
</xsl:foreach>
</body>
</html>
</xsl:template>
. :
HTML ,
<title>.
,
, <xsl:valueof>
, <b>, ,
.
SEX .
,
, ,
XSLT.
,
.
,
GEDCOM <INDI>:
, . .
.
CSS,
cssstyle.
:
<xsl:template name="cssstyle">
<style type="text/css">
717
H1 {
fontfamily: Verdana, Helvetica, sansserif;
fontsize: 18pt;
fontweight: bold;
color: "#FF0080"
}
H2 {
fontfamily: Verdana, Helvetica, sansserif;
fontsize: 14pt;
fontweight: bold;
color: black;
}
H3 {
fontfamily: Lucida Sans, Helvetica, sansserif;
fontsize: 11pt;
fontweight: bold;
color: black;
}
SPAN.label {
fontfamily: Lucida Sans, Helvetica, sansserif;
fontsize: 10pt;
fontweight: normal;
fontstyle: italic;
color: black;
}
P,LI,TD {
fontfamily: Lucida Sans, Helvetica, sansserif;
fontsize: 10pt;
fontweight: normal;
color: black;
}
P.text {
fontfamily: Comic Sans MS, Helvetica, sansserif;
fontsize: 10pt;
fontweight: normal;
color: black;
}
</style>
</xsl:template>
, ,
HTML ,
XSLT, , XSLT
CSS .
CSS, ,
HTML,
.
718
10.
:
<xsl:template name="showparents">
<xsl:variable name="parents" select="key('fam', FAMC/@REF)"/>
<xsl:variable name="father" select="key('indi', $parents/HUSB/@REF)"/>
<xsl:variable name="mother" select="key('indi', $parents/WIFE/@REF)"/>
<p>
<xsl:if test="$father">
<span class="label">Father: </span>
<xsl:applytemplates select="$father/NAME" mode="link"/> 
</xsl:if>
<xsl:if test="$mother">
<span class="label">Mother: </span>
<xsl:applytemplates select="$mother/NAME" mode="link"/> 
</xsl:if>
</p>
</xsl:template>
<FAM>,
<FAMC> <INDI>.
fam, . , indi,
<INDI> , <HUSB>
<WIFE> <FAM>.
, , <FAMC>,
<FAM> <HUSB> <WIFE> ( ),
$father $mother
. <xsl:if> ,
.
<xsl:applytemplates>
mode="link".
, , .
  .
, ,
<xsl:text>. ,
<!DOCTYPE> nbsp
 .
, .
( ,
).
<xsl:template name="showevents">
<xsl:foreach select="*">
<xsl:sort select="substring(DATE, stringlength(DATE) 3)"/>
<xsl:variable name="eventname">
<xsl:applytemplates select="." mode="expand"/>
719
</xsl:variable>
<xsl:if test="string($eventname)">
<h3><xsl:valueof select="$eventname"/></h3>
<p>
<xsl:if test="DATE">
<span class="label">Date: </span>
<xsl:valueof select="DATE"/><br/>
</xsl:if>
<xsl:if test="PLAC">
<span class="label">Place: </span>
<xsl:valueof select="PLAC"/><br/>
</xsl:if>
</p>
<xsl:foreach select="NOTE">
<p class="text"><xsl:applytemplates/></p>
</xsl:foreach>
</xsl:if>
</xsl:foreach>
</xsl:template>
.
<xsl:sort>,
<DATE>, ,
. GEDCOM 21 APR 1862.
,
BETWEEN 1865 AND 1868. 55 BC (55 . .)
, , , .
(
,
). , ,
, GEDCOM
ISO, .
, .
GEDCOM ,
select="BIRT | DEAT |
BAPM | BURI", . ,
( BURI)
, Burial ().
, , ex
pand: ,
, .
,
$eventname .
, .
<xsl:if test="$eventname"/>,
, .
,
string(), .
720
10.
, ,
. ,
:
<xsl:template match="BIRT" mode="expand">Birth</xsl:template>
<xsl:template match="DEAT" mode="expand">Death</xsl:template>
<xsl:template match="BURI" mode="expand">Burial</xsl:template>
<xsl:template match="BAPM" mode="expand">Baptism</xsl:template>
<xsl:template match="MARR" mode="expand">Marriage</xsl:template>
<xsl:template match="EVEN" mode="expand">
<xsl:valueof select="TYPE"/>
</xsl:template>
<xsl:template match="*" mode="expand"/>
<EVEN> GEDCOM,
<TYPE>,
. , , , , ,
, GEDCOM
. ,
, ,
.
HTML ,
() .
<INDI>
<FAMS>. Partner 1,
Partner 2; , .
, <FAM>,
;
$partnerships.
,
<HUSB>, <WIFE>.
,
, .
,
.
, ,
, ( !),
.
:
<xsl:template name="showpartners">
<xsl:variable name="subject" select="."/>
<xsl:variable name="partnerships"
select="key('fam', FAMS/@REF)"/>
<xsl:foreach select="$partnerships">
<xsl:sort select="substring(MARR/DATE,
stringlength(MARR/DATE) 3)"/>
721
<xsl:variable name="partner"
select="key('indi',
(HUSB/@REF | WIFE/@REF)[.!=$subject/@ID])"/>
<xsl:variable name="partnerseq">
<xsl:choose>
<xsl:when test="count($subject/FAMS)=1"></xsl:when>
<xsl:otherwise>
<xsl:valueof select="position()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$partner">
<h2>Partner <xsl:valueof select="$partnerseq"/></h2>
<p>
<xsl:applytemplates select="$partner/NAME" mode="link"/>
</p>
</xsl:if>
<xsl:calltemplate name="showevents"/>
<xsl:variable name="children" select="key('indi', CHIL/@REF)"/>
<xsl:if test="$children">
<p><span class="label">Children:</span><br/>
<xsl:foreach select="$children">
<xsl:sort select="substring(BIRT/DATE,
stringlength(BIRT/DATE) 3)"/>
<xsl:valueof select="substring(BIRT/DATE,
stringlength(BIRT/DATE) 3)"/>
<xsl:text> </xsl:text>
<xsl:applytemplates select="NAME" mode="link"/><br/>
</xsl:foreach>
</p>
</xsl:if>
</xsl:foreach>
</xsl:template>
,
. ,
.
, ( ) ,
, , .
<CHIL> <FAM> ,
.
HTML:
<xsl:template match="NAME" mode="link">
<a>
<xsl:attribute name="href">
<xsl:calltemplate name="makehref"/>
</xsl:attribute>
722
10.
<xsl:applytemplates/>
</a>
</xsl:template>
<xsl:template match="S">
<xsl:text> </xsl:text>
<b><u><xsl:applytemplates/></u></b>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template name="makehref">
<xsl:valueof select="concat(../@ID, '.html')"/>
</xsl:template>
makehref , :
URL HTML,
ID , I27.html.
<BR>,
:
<xsl:template match="BR"><BR/></xsl:template>
</xsl:transform>
, , HTML
.
!
, .
HTML, ;
. .
HTML
HTML ,
, ,
. XSLT 1.1
.
, XSLT 1.0,
, , , .
, ,
, person.xsl,
<xsl:import>,
.
, publish.xsl,
. HTML
723
, ,
, , .
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1" >
<xsl:import href="person.xsl"/>
<xsl:param name="dir" select="'.'"/>
<xsl:template match="/">
<xsl:foreach select="*/INDI">
<xsl:document href="{$dir}/{@ID}.html">
<xsl:applytemplates select="."/>
</xsl:document>
</xsl:foreach>
<xsl:document href="{$dir}/index.html">
<xsl:calltemplate name="makeindex"/>
</xsl:document>
</xsl:template>
<xsl:template name="makeindex">
<html>
<head>
<title>Index of names</title>
</head>
<body>
<h1>Index of names</h1>
<p>
<xsl:foreach select="/*/INDI/NAME">
<xsl:sort select="S"/>
<xsl:sort select="text()"/>
<a>
<xsl:attribute name="href">
<xsl:calltemplate name="makehref"/>
</xsl:attribute>
<xsl:valueof select="S"/>,
<xsl:foreach select="text()">
<xsl:valueof select="concat(' ', ., ' ')"/>
</xsl:foreach>
</a>
<br/>
</xsl:foreach>
</p>
</body>
</html>
</xsl:template>
</xsl:transform>
XSLT,
XSLT1.1 <xsl:document>,
, XSLT1.0,
724
10.
.
,
, Saxon.
, Saxon,
http://users.iclway.co.uk/mhkay/saxon/. Windows
Instant Saxon,
.
, Wrox.
, XML
, :
saxon kennedy.xml publish.xsl
, saxon.exe PATH; ,
c:\saxondir\saxon,
c:\saxondir.
HTML ,
, , :
saxon kennedy.xml publish.xsl dir=d:\jfk
HTML.
index.html .
, . 10.3.
, .
HTML
XML
HTML HTML
. , ,
, ASP, Java
CGI. XSLT
Java, .
, ,
, ,
. , Professional
Java Server Programming, ISBN: 1861002777,
Wrox Press.
, Saxon Xalan,
TrAX API, F;
, Java, Oracle,
. ,
, .
,
,
. ,
725
, ,
.
,
,
,
. ,
,
XML
.
, :
http://www.myserver.com/examples/servlet/GedServlet?tree=kennedy&id=I1
, URL, , ,
(,
), , ,
, .
URL XML, &
&. HTML
: & &, HTML,
.
, ,
. , ,
person.xsl ,
. gedservlet.xsl.
gedservlet.xsl .
,
. , makehref
, :
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xsl:import href="person.xsl"/>
<xsl:param name="tree"/>
<xsl:template name="makehref">
<xsl:valueof select="concat('/examples/servlet/GedServlet?tree=',
$tree, '&id=', ../@ID)"/>
</xsl:template>
</xsl:transform>
,
URL.
726
10.
,
, ,
,
.
. , ,
TrAX, F, XSLT
, API.
Xalan javax.xml.transform, javax.xml.parsers,
Saxon javax.xml.transform.
Saxon
, javax.xml.parsers:
Crimson http://xml.apache.org/.
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Hashtable;
import org.w3c.dom.Document;
import
import
import
import
import
javax.xml.parsers.*;
javax.xml.transform.*;
javax.xml.transform.stream.*;
javax.xml.transform.dom.*;
org.xml.sax.SAXException;
727
res.getOutputStream().
println("Error applying stylesheet: " + err.getMessage());
}
}
/**
* ;
*/
private synchronized Templates getStyleSheet()
throws TransformerConfigurationException {
if (stylesheet == null) {
File sheet =
new File(getServletContext().getRealPath("/gedservlet.xsl"));
stylesheet = TransformerFactory.newInstance().
newTemplates(new StreamSource(sheet));
}
return stylesheet;
}
/**
*
*/
private synchronized Document getSourceDocument(String tree)
throws ParserConfigurationException, SAXException {
Document doc = (Document)trees.get(tree);
if (doc==null) {
File source =
new File(getServletContext().getRealPath("/" + tree + ".xml"));
doc = DocumentBuilderFactory.newInstance().
newDocumentBuilder().parse(source);
}
return doc;
}
/**
* ,
*/
private synchronized void resetData() {
trees = new Hashtable();
stylesheet = null;
}
private Hashtable trees = new Hashtable();
private Templates stylesheet = null;
}
XML, ,
tree.xml, tree ,
kennedy.xml.
, ,
728
10.
. : person.xsl ged
servlet.xsl, .
(
TrAX Templates) ,
. , DOM Document,
.
. ,
, ,
.
TrAX
Transformer,
.
, renderDocument(),
( URL)
.
HTML ASP
Microsoft Java
ASP. , ,
XSLT Microsoft MSXML3.
MSXML3
, .
COM, ASP ,
COM. API
MSXML3 A.
HTML ,
ASP.
,
, , .
gedasp.xsl:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:import href="person.xsl"/>
<xsl:param name="tree"/>
<xsl:template name="makehref">
<xsl:valueof select="concat('GedAsp.asp?tree=', $tree, '&id=', ../@ID)"/>
</xsl:template>
</xsl:transform>
729
ASP ,
.
.
ASP ( ,
):
<%@ LANGUAGE = JScript %>
<%
// URL
var family = Request.QueryString("tree") + "";
var indi = Request.QueryString("id") + "";
//
var sourceFile = Server.MapPath("kennedy.xml");
var styleFile = Server.MapPath("gedasp.xsl");
// XML
var source = new ActiveXObject("MSXML2.DOMDocument");
source.async = false;
source.load(sourceFile);
// XSLT
var style = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
style.async = false;
style.load(styleFile);
var transformer = new ActiveXObject("MSXML2.XSLTemplate");
transformer.stylesheet = style.documentElement;
var xslproc = transformer.createProcessor();
xslproc.input = source;
//
xslproc.addParameter("id", indi, "");
xslproc.addParameter("tree", family, "");
//
xslproc.transform();
Response.Write(xslproc.output);
%>
HTML
,
: XML
.
Internet Explorer 5
XML MSXML3 Microsoft (
,
).
A.
730
10.
XML ( ,
),
.
:
.
,
. ,
,
, ,
.
XSLT ,
,
MSXML3.
JavaScript HTML
famtree.html. . <script>
JavaScript.
<html>
<head>
<title>Family Tree</title>
<style type="text/css">
... ...
</style>
<script>
var source = null;
var style = null;
var transformer = null;
function init() {
source =
new ActiveXObject("MSXML2.DOMDocument");
source.async = false;
source.load('kennedy.xml');
style =
new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
style.async = false;
style.load('msperson.xsl');
transformer = new ActiveXObject("MSXML2.XSLTemplate");
transformer.stylesheet = style.documentElement;
refresh("I1");
}
function refresh(indi) {
var xslproc = transformer.createProcessor();
xslproc.input = source;
xslproc.addParameter("id", indi, "");
xslproc.transform();
displayarea.innerHTML = xslproc.output;
}
731
</script>
<script for="window" event="onload">
init();
</script>
</head>
<body>
<div id="displayarea"></div>
</body>
</html>
CSS XSLT
HTML, .
init().
DOM: XML, ,
, URL kennedy.xml msperson.xsl.
XSLTemplate TrAX Templates.
, refresh()
I1.
. , GEDCOM
.
,
.
refresh()
createProcessor() XSLTemplate.
id
, transform(). HTML,
,
<div id="displayarea"> HTML.
. ,
, I2, :
<a href="Javascript:refresh('I2')">Jaqueline Lee Bouvier</a>
,
refresh(),
, id.
,
.
msperson.xsl
person.xsl, ,
. :
CSS,
HTML. :
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
732
10.
version="1.0"
>
<xsl:import href="person.xsl"/>
<! >
<xsl:template name="makehref">
<xsl:variable name="apos">'</xsl:variable>
<xsl:valueof
select="concat('Javascript:refresh(', $apos, ../@ID, $apos, ')')"/>
</xsl:template>
<! CSS >
<xsl:template name="cssstyle"/>
</xsl:transform>
:
HTML <html>, <head> <body>,
<div> HTML.
, Internet Explorer
HTML, ,
() HTML.
.
( , ),
JavaScript,
HTML.
match="INDI" person.xsl
, ,
HTML.
,
.
GEDCOM XML
, GEDCOM,
, XML,
XML. ,
.
,
GEDCOM. http://
www.cyndislist.com/software.htm.
Personal Ancestral File, PAF.
GEDCOM XML
, GEDCOM
XML. :
GEDCOM, SAX
733
XML, ,
SAX, GEDCOM ,
? , XSLT
SAX ,
GEDCOM .
XSLT
DocumentHandler SAX,
SAX2 ContentHandler, XSLT
GEDCOM. ,
,
GEDCOM , XML
.
nonliving.xsl,
,
, , .
Wrox
SAX2 GEDCOM; GedcomParser.
GEDCOM ANSEL,
GedcomParser AnselInputStreamReader
ANSEL Unicode.
SAX2 ContentHandler
GedcomOutputter, , ,
Unicode ANSEL, AnselOutputStreamWriter.
:
. 10.4. GEDCOM
734
10.
XML, GEDCOM
, .
:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xsl:template match="/">
<xsl:copyof select="."/>
</xsl:template>
</xsl:transform>
kennedy.xml,
,
, ,
GEDCOM.
normalize.xsl ,
GEDCOM, XML. :
GEDCOM Michael /Kay/, XML
, :
Michael <S>Kay</S>.
GEDCOM CONT
CONC: CONT , CONC
. normalize.xsl
CONC, CONT <BR/>, HTML.
, , ,
GEDCOM mytree.ged XML, Saxon,
saxon x GedcomParser mytree.ged normalize.xsl >mytree.xml
,
XSLT
.
:
XML.
XML:
HTML
.
735
HTML , Java
ASP Microsoft.
HTML .
XSLT ,
XML.
XML
XSLT .
,
XSLT,
.
,
,
.
,
32.
. 10.5. , e5
.
ah, , 18, .
.
.
,
.
;
Wrox tour.xsl.
, , XSLT 1.1
, ,
.
$board/square, XSLT 1.0 .
736
10.
Saxon.
XSLT 1.0 node
set(), ,
: , $board/square xx:nodeset($board)/square.
,
MSXML3 Microsoft mstour.xsl. ,
,
XSLT 1.0.
, . , ,
tour10.xsl.
(Oren BenKiki),
. ,
.
,
, ,
, ,
. ,
, ,
,
.
,
, , ,
.
, , .
, ,
, .
.
, ,
. , , ,
,
, . XSLT 1.0
,
; XSLT 1.1
, .
, 64 <square>,
.
1 64, (
), ,
.
, ,
.
737
XSLT , .
, ,
,
.
, ,
, . 10.6:
. 10.6.
, 0 7 0 7,
8 + .
, .
:
( ,
)
63 ,
:
(
, )
. ,
, , ,
. ,
.
738
10.
:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
<xsl:param name="start" select="'a1'"/>
<! startcolumn 07 >
<xsl:variable name="startcolumn"
select="number(translate(substring($start, 1, 1),
'abcdefgh', '01234567'))"/>
<! startrow 07, >
<xsl:variable name="startrow"
select="8 number(substring($start, 2, 1))"/>
. . .
</xsl:transform>
start,
, :
.
:
start a1.
, ;
, XML. select="a1",
<a1> .
(ah) (07)
translate(), 7.
8,
.
063.
, .
.
. ,
,
.
:
HTML
739
,
:
<xsl:template match="/">
<! >
<xsl:if test="not(stringlength($start)=2) or
not(translate(substring($start,1,1), 'abcdefgh', 'aaaaaaaa')='a') or
not(translate(substring($start,2,1), '12345678', '11111111')='1')">
<xsl:message terminate="yes"
> : () 'a1' or 'f6'</xsl:message>
</xsl:if>
<! >
<xsl:variable name="emptyboard">
<xsl:calltemplate name="makeboard"/>
</xsl:variable>
<! >
<xsl:variable name="initialboard">
<xsl:calltemplate name="placeknight">
<xsl:withparam name="move" select="1"/>
<xsl:withparam name="board" select="$emptyboard"/>
<xsl:withparam name="square"
select="$startrow * 8 + $startcolumn"/>
</xsl:calltemplate>
</xsl:variable>
<! >
<xsl:variable name="finalboard">
<xsl:calltemplate name="makemoves">
<xsl:withparam name="move" select="2"/>
<xsl:withparam name="board" select="$initialboard"/>
<xsl:withparam name="square"
select="$startrow * 8 + $startcolumn"/>
</xsl:calltemplate>
</xsl:variable>
<! HTML >
<xsl:calltemplate name="printboard">
<xsl:withparam name="board" select="$finalboard"/>
</xsl:calltemplate>
</xsl:template>
, <xsl:call
template> <xsl:variable>.
. <xsl:variable>
, , ,
. ,
.
start.
:
740
10.
, ah
18.
translate() .
,
<xsl:message> .
(emptyboard, initialboard finalboard)
, .
, : ,
64 <square>. , XPath
XML,
, <square>.
, ,
(1 , 2
, ). ,
.
063,
$row 8 + $column.
, .
makeboard, .
64
<square/>, , :
<xsl:template name="makeboard">
<xsl:param name="size" select="64"/>
<xsl:if test="$size!=0">
<square/>
<xsl:calltemplate name="makeboard">
<xsl:withparam name="size" select="$size 1"/>
</xsl:calltemplate>
</xsl:if>
</xsl:template>
, $size
64.
( <square/>), ,
63. 64 $size
; 64 ,
.
,
placeknight. :
<xsl:template
<xsl:param
<xsl:param
<xsl:param
name="placeknight">
name="move"/>
name="board"/>
name="square"/>
741
: ,
, .
,
,
.
,
.
<square>, . ,
<square>5</square>.
, , . XSLT
.
. (,
) ,
.
, ,
HTML.
. HTML printrows
:
<xsl:template name="printboard">
<xsl:param name="board"/>
<html>
<head>
<title> </title>
</head>
<body>
<div align="center">
<h1> <xsl:valueof select="$start"/></h1>
<table border="1" cellpadding="4">
<xsl:calltemplate name="printrows">
<xsl:withparam name="board" select="$board"/>
</xsl:calltemplate>
</table>
</div>
</body>
</html>
</xsl:template>
.
( printcolumns), ,
742
10.
. ,
:
<xsl:template name="printrows">
<xsl:param name="board"/>
<xsl:param name="row" select="0"/>
<xsl:if test="$row < 8">
<tr>
<xsl:calltemplate name="printcolumns">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="row" select="$row"/>
</xsl:calltemplate>
</tr>
<xsl:calltemplate name="printrows">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="row" select="$row + 1"/>
</xsl:calltemplate>
</xsl:if>
</xsl:template>
printcolumns . ,
.
<xsl:template name="printcolumns">
<xsl:param name="board"/>
<xsl:param name="row"/>
<xsl:param name="column" select="0"/>
<xsl:if test="$column < 8">
<xsl:variable name="color">
<xsl:choose>
<xsl:when test="($row + $column) mod 2">xffff44</xsl:when>
<xsl:otherwise>white</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<td align="center" bgcolor="{$color}">
<xsl:valueof select="$board/square[$row*8 + $column + 1]"/>
</td>
<xsl:calltemplate name="printcolumns">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="row" select="$row"/>
<xsl:withparam name="column" select="$column + 1"/>
</xsl:calltemplate>
</xsl:if>
</xsl:template>
,
. mod ,
2 ,
<xsl:choose>.
743
,
<square> ,
.
, ,
: .
,
, ,
, . ,
c2, a1, e1, a3, e3, b4
d4, , . a1
b3,
, . ,
,
, ,
.
makemoves. ,
, ,
. ,
: ,
, , ,
trypossiblemoves.
, makemoves, listpossib
lemoves .
,
.
, <move>,
, .
, trypossiblemoves
.
. (
2, 1),
,
.
<xsl:template name="makemoves">
<xsl:param name="move"/>
<xsl:param name="board"/>
<xsl:param name="square"/>
<! >
<xsl:variable name="possiblemovelist">
<xsl:calltemplate name="listpossiblemoves">
<xsl:withparam name="board" select="$board"/>
744
10.
<xsl:withparam name="square" select="$square"/>
</xsl:calltemplate>
</xsl:variable>
<! , >
<xsl:calltemplate name="trypossiblemoves">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="square" select="$square"/>
<xsl:withparam name="move" select="$move"/>
<xsl:withparam name="possiblemoves" select="$possiblemovelist/move"/>
</xsl:calltemplate>
</xsl:template>
listpossiblemoves.
, . ,
, . ,
,
, . 10.7.
. 10.7.
,
, , ,
, .
:
:
<xsl:template name="listpossiblemoves">
<xsl:param name="board"/>
<xsl:param name="square"/>
<xsl:variable name="row" select="$square div 8"/>
<xsl:variable name="column" select="$square mod 8"/>
<xsl:if test="$row > 1 and $column > 0
and $board/square[($square 17) + 1]=''">
<move><xsl:valueof select="$square 17"/></move>
</xsl:if>
<xsl:if test="$row > 1 and $column < 7
and $board/square[($square 15) + 1]=''">
745
, ,
. trypossiblemoves.
, .
, .
, <xsl:otherwise>,
, ##, ,
.
,
, , , .
,
findbestmove, (
). ,
,
, , ,
.
, placeknight,
.
.
746
10.
, , XSLT
.
( <square/>),
makemoves, ,
. ,
.
64 $finalboard
, printboard
.
<xsl:template
<xsl:param
<xsl:param
<xsl:param
<xsl:param
name="trypossiblemoves">
name="move"/>
name="board"/>
name="square"/>
name="possiblemoves"/>
<xsl:choose>
<xsl:when test="$possiblemoves">
<! , >
<xsl:variable name="bestmove">
<xsl:calltemplate name="findbestmove">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="possiblemoves" select="$possiblemoves"/>
</xsl:calltemplate>
</xsl:variable>
<! , >
<xsl:variable name="otherpossiblemoves"
select="$possiblemoves[. != $bestmove]"/>
<! , , >
<xsl:variable name="nextboard">
<xsl:calltemplate name="placeknight">
<xsl:withparam name="move" select="$move"/>
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="square" select="$bestmove"/>
</xsl:calltemplate>
</xsl:variable>
<! , >
<xsl:variable name="finalboard">
<xsl:choose>
<xsl:when test="$nextboard/square = ''">
<! if there is an empty square >
<xsl:calltemplate name="makemoves">
<xsl:withparam name="move" select="$move + 1"/>
<xsl:withparam name="board" select="$nextboard"/>
<xsl:withparam name="square" select="$bestmove"/>
</xsl:calltemplate>
</xsl:when>
<xsl:otherwise>
<xsl:copyof select="$nextboard"/>
</xsl:otherwise>
747
</xsl:choose>
</xsl:variable>
<! '##',
.
.
. >
<xsl:choose>
<xsl:when test="$finalboard='##'">
<xsl:calltemplate name="trypossiblemoves">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="square" select="$square"/>
<xsl:withparam name="move" select="$move"/>
<xsl:withparam name="possiblemoves" select="$otherpossiblemoves"/>
</xsl:calltemplate>
</xsl:when>
<xsl:otherwise>
<xsl:copyof select="$finalboard"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<! , '##'
, ,
<xsl:valueof select="'##'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
>
findbestmove,
.
, .
,
.
( ) , ,
,
.
.
,
placeknight, ,
.
listpossiblemoves, , ,
. ,
, .
:
,
, , .
748
10.
, . ,
findbestmove
. ,
, , .
<xsl:template
<xsl:param
<xsl:param
<xsl:param
<xsl:param
name="findbestmove">
name="board"/>
name="possiblemoves"/>
name="fewestexits" select="9"/>
name="bestsofar" select="'XX'"/>
749
<xsl:valueof select="$bestsofar"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<! ,
. . >
<xsl:choose>
<xsl:when test="$otherpossiblemoves">
<xsl:calltemplate name="findbestmove">
<xsl:withparam name="board" select="$board"/>
<xsl:withparam name="possiblemoves" select="$otherpossiblemoves"/>
<xsl:withparam name="fewestexits" select="$minimumexits"/>
<xsl:withparam name="bestsofar" select="$newbestsofar"/>
</xsl:calltemplate>
</xsl:when>
<xsl:otherwise>
<xsl:valueof select="$newbestsofar"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Wrox
(, ).
Saxon :
saxon tour.xsl tour.xsl start=b6 >tour.html
tour.html .
, XSLT:
, a1.
XSLT 1.1.
XSLT 1.0,
. ,
MSXML3, msxsl:nodeset(),
mstour.xsl.
<?xmlstylesheet?>, ,
( ),
Windows.
,
XSLT
, ,
750
10.
.
XSLT ,
,
,
,
.
, , ,
: , , ,
, , XSLT
.
,
,
.
, ,
, , :
, ,
, , HTML.
HTML XML
, ,
.
.
XML,
XPath.
XSLT: XML
HTML , XML.
. ,
XSLT,
.
XSLT 1.1, XSLT 1.0,
.
, XSLT.
XSLT.
A
Microsoft MSXML3
MSXML3 Microsoft, XSLT 1.0,
XML .
MSXML3 Microsoft
XML XSLT.1 XML,
DOM,
W3C DOM Recommendation, XSLT,
W3C XSLT 1.0 Recommendation,
XPath 1.0,
XSLT DOM. MSXML3
XML,
XML, Microsoft (
W3C XML).
MSXML 1998
, IE4, IE5 IE5.5.
XSL,
, , .
Microsoft. XSLT
1998 XSLT 1.0 XSLT 1.1,
, .
WDxsl ( XSL, Working Draft
XSL), , ,
: xmlns:xsl="http://www.w3.org/
1
752
. Microsoft MSXML3
TR/WDxsl", xmlns:xsl="http://www.w3.org/
1999/XSL/Transform".
Microsoft XSL WDxsl.
XSLT, .
MSXML3
,
, Internet Explorer, Win
dows 2000 SQL Server.
MSXML, WDxsl.
MSXML3
Microsoft http://msdn.microsoft.com/xml/.
MSXML3: ,
XSLT 1.0.
Internet Explorer,
.
, MSXML , , ASP.
,
MSXML API.
MSXML
Microsoft
MSXML. 1.0 2.0,
Internet Explorer 5
5.5, Windows 2000.
SDK, Internet Explorer Windows SDK.
MSXML
XML XSLT.
XSLT,
MSXML (MSXML parser). , 2.0
XSL 1998
, Microsoft,
,
W3C, XML
.
MSXML 3.0 2000 ,
, ,
2000 . ,
Internet Explorer 6.
, Microsoft,
.
MSXML3 WDxsl, XSLT.
, ,
MSXML3
753
. URI ,
<xsl:stylesheet>:
WDxsl URI:
http://www.w3.org/TR/WDxsl
XSLT
URI:
http://www.w3.org/1999/XSL/Transform
WDxsl,
XSLT, . XSLT
WDxsl, : , ,
, , <xsl:import>, XPath.
, .
, ,
IE5,
WDxsl. ,
, , ,
. ,
. WDxsl
MSXML3; Microsoft,
, Microsoft XSLT.
MSXML3
MSXML3 XSLT 1.0.
XSLT 1.1, . MSXML3
, :
(
XSLT 1.0) .
,
, , ,
, . ,
$/, <xsl:applytemplates select="$"> <xsl:for
each select="$">. :
msxsl:nodeset()
.
<xsl:document>. , MSXML3
,
. ,
,
754
. Microsoft MSXML3
, .
JScript,
.
XML.
<xsl:sript>
. , MSXML3 <msxsl:script>
. Microsoft
,
Microsoft, JScript VBScript,
Java. COM
, JScript.
MSXML3 .
,
VBScript JScript
<msxsl:script>. <xsl:script>,
XSLT 1.1.
, :
: VBScript
MSXML3
,
.
.xml.
,
Windows.
<?xml version="1.0" encoding="utf8"?>
<?xmlstylesheet type="text/xsl" href=".xsl"?>
<>
<>5</>
<>12</>
</>
MSXML3
755
.xsl.
, VBScript,
<msxsl:script>.
<> .
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:extra="urn:extrafunctions"
>
<msxsl:script xmlns:msxsl="urn:schemasmicrosoftcom:xslt"
language="VBScript"
implementsprefix="extra"
>
Function ToMillimetres(inches)
ToMillimetres = inches * 25.4
End Function
</msxsl:script>
<xsl:output method="html"/>
<xsl:template match="/" >
<html><body><p>
<xsl:applytemplates/>
</p></body></html>
</xsl:template>
<xsl:template match="">
<xsl:text> </xsl:text>
<xsl:valueof select="formatnumber(extra:ToMillimetres(number(.)), '0.00')"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
:
127.00 304.80.
COM,
.
.
, , ,
HTML, ,
, HTML,
.
, . ,
XPath, ,
<msxsl:script>.
756
. Microsoft MSXML3
<script>,
, HTML,
.
msxsl:nodeset()
MSXML3 XSLT 1.0,
, XSLT 1.0 ,
( ).
,
, :
<xsl:variable name="">
<></>
</xsl:variable>
, , ,
:
, $/
<xsl:foreach>
<xsl:applytemplates>
, MSXML3,
XSLT 1.0, ,
.
, . :
<xsl:valueof select="count(msxsl:nodeset($)/)"/>
<xsl:foreach select="msxsl:nodeset($)">
<xsl:applytemplates select="msxsl:nodeset($)"/>
URI nodeset() ( ,
<msxsl:script>) xmlns:msxsl="urn:schemasmicrosoftcom:xslt". ,
,
URI.
systemproperty() MSXML3
:
xsl:version
xsl:vendor
Microsoft
xsl:vendoruri
http://www.microsoft.com
msxsl:version
MSXML3
757
Microsoft
XSLT 1.0 XPath 1.0.
XSLT ,
.
, ,
, .
,
, . :
. XSLT
Microsoft DOM,
DOM MSXML3 ,
. ,
<xsl:preservespace> ,
, XSLT ,
, .
,
preserveWhitespace DOMDocument
True. :
<xsl:text>
, , ,
, ,
preserveWhitespace, True.
. XSLT XPath
, .
MSXML3
DOM, . MSXML3
DOM XPath,
. ,
: ,
CDATA XML, ,
(
, <).
, <xsl:valueof select="text()"/>,
MSXML3 ,
,
CDATA.
<xsl:valueof select="."/>.
<xsl:message> ,
terminate="yes".
758
. Microsoft MSXML3
MSXML3
MSXML3
Microsoft. , :
http://msdn.microsoft.com/downloads/webtechnology/xml/msxml.asp
msxml3.exe ,
.
, ,
, SDK, , .
.
xmlsdk.exe
.
HTML xmlsdk.chm,
c:\Program Files\Microsoft XML Parser SDK\Docs
Windows.
MSXML3
MSXML, IE5 IE5.5.
,
, , ,
Internet Explorer. XSLT ,
, MSXML3 :
, Internet
Explorer, MSXML3.
xmlinst.exe,
Microsoft MSDN.
MSXML3
, , SQL Server Biztalk Server.
MSXML2.
,
Microsoft XML,
http://msdn.microsoft.com/xml/default.asp. ,
XML .
,
:
Internet Explorer,
XML XSLT.
Internet Explorer
:
XML XSLT.
.
Microsoft XSL ISAPI.
XML/XSL .
759
MSXML3
,
.
,
. ,
, ,
MSXML2 MSXML3.
XSL XSLT.
, WDxsl , XSLT,
MSXML3
.
, .
, Internet Explorer (IE5 IE5.5)
, MSXML3 .
, MSXML3
.
ProgID ClassID
MSXML 2.0
ProgID:
Microsoft.XMLDOM MSXML.DOMDocument
msxml.dll
ClassID:
{2933bf907b3611d2b20e00c04f983e60}
MSXML 2.6
msxml2.dll
ProgID:
MSXML2.DOMDocument
ClassID:
{f6d90f119c7311d3b32e00c04f990bb4}
760
. Microsoft MSXML3
DLL
ProgID ClassID
MSXML 3.0
ProgID:
MSXML2.DOMDocument.3.0
msxml3.dll
ClassID:
{f5078f32c55111d389b90000f81fe221}
.
"DOMDocument",
XML, Microsoft
(W3C Document Object Model), DOM.
Document load,
XML. , ,
XML. XML
Document, Parser .
Microsoft :
, (
), , ().
ProgID ClassID
(normal apartmentthre
aded mode).
(freethreaded mode), ProgID ClassID
(,
ClassID ).
, , MSXML3
,
Application.
ProgID ClassID
MSXML 2.0
ProgID:
Microsoft.FreeThreadedXMLDOM
MSXML.FreeThreadedDOMDocument
ClassID:
{2933bf917b3611d2b20e00c04f983e60}
MSXML 2.6
ProgID:
MSXML2.FreeThreadedDOMDocument
ClassID:
{f6d90f129c7311d3b32e00c04f990bb4}
MSXML 3.0
ProgID:
MSXML2.FreeThreadedDOMDocument.3.0
ClassID:
{f5078f33c55111d389b90000f81fe221}
MSXML3
761
MSXML
xmlinst.exe.
, ,
MSXML.
(
) ,
ProgID MSXML.DOMDocument
, 2.0. ,
ProgID. Running
MSXML3 in Replace Mode ( XML Developer's Guide/XML DOM Us
er Guide) ,
xmlinst.exe .
xmlinst.exe, Internet Explorer
MSXML,
, .
( . 763), XML,
<?xmlstylesheet?>
XSLT,
. ,
, XSLT ,
MSXML3
xmlinst.exe.
WDxsl, MSXML3 .
, ,
,
MSXML3. ,
Microsoft.
762
. Microsoft MSXML3
, MSXML3
, ,
SQL Server BizTalk Server. ,
MSXML2. MSXML3
(
) ProgID
MSXML2.DOMDocument.3.0 MSXML2.FreeThreadedDOMDocument.3.0.
XML,
, Internet Explorer
.
(. .1).
, , , ,
.
, .
, .
, ,
(. .2).
XSLT
763
. .2. XML
,
, URL: res://msxml.dll/
DEFAULTSS.XSL ( URL res://msxml3.dll/
DEFAULTSS.XSL, MSXML3).
WDxsl.
URI http://www.w3.org/TR/WDxsl,
XSL, <xsl:entityref> <xsl:nodename>.
XSLT
XSLT
XML.
:
<?xmlstylesheet type="text/xsl" href="url__"?>
,
.xsl, , XML,
:
<?xmlstylesheet type="text/xsl" href=".xsl"?>
764
. Microsoft MSXML3
MSXML3 <?xml
stylesheet?> XML, type="text/xsl",
XSLT WDxsl. , ,
XML (Cascading Styleshe
ets, CSS) <?xmlstylesheet?>,
( type="text/css"),
. Internet Explorer XSL,
,
CSS, ,
<LINK>, CSS HTML.
,
<?xmlstylesheet?>, 3, XSLT In
ternet Explorer , type href. type
text/xsl, , MIME,
W3C.
XML, Internet
Explorer ,
. 763. , , ,
, XML
.
XML,
XSLT, ,
. ,
XSLT,
. .4.
, ,
, .
XSLT
765
. .4. ,
XSLT
,
. ,
, Saxon Xalan, ,
.
,
.
, , , MSXML3
.
, , ,
.
,
, .
msxsl.exe
Microsoft,
. MSDN;
60 , .
, :
MSXML source.xml style.xsl o out.xml param=value
, ,
(
, 400 ):
Error occurred while compiling stylesheet 'test75.xsl'.
Code: 0x80004005
Expected token 'eof' found 'NUMBER'.
1.2>.2<
,
. ,
. ,
XSLT : select="",
select="" select="''",
, <>
.
766
. Microsoft MSXML3
View Source
, ,
XML. ,
HTML.
Microsoft XSLT
. ; ,
MSDN.
(
.inf install), ,
, . ,
Internet Explorer View
XSL Output ( XSL).
HTML,
.
HTML ,
. ,
:
<xsl:comment> xyz</xsl:comment>
,
XSL. (
XSLT <xsl:message>, MSXML3
,
terminate="yes").
,
. MSXML3
, .
XSLT
, .
Xalan, , , Saxon
.
XSLT
<?xmlstylesheet?>
XML.
, HTML
, XML
.
ProgID ClassID.
XSLT
767
MSXML
DOM,
MSXML3, .
VBScript:
Dim doc
Set doc = CreateObject("MSXML2.DOMDocument.3.0")
JScript:
var doc = new ActiveXObject('MSXML2.DOMDocument.3.0');
CreateObject:
Dim doc
Set doc = CreateObject("MSXML2.DOMDocument.3.0")
New,
.
Dim doc As New DOMDocument3.0
XML XSLT
Document Mic
rosoft . XML
load:
768
. Microsoft MSXML3
XML , (
XML SQL ADO),
loadXML:
' VBScript Visual Basic:
Dim strXML
strXML = "<?xml version='1.0'?><test><testitem/></test>"
doc.LoadXML strXML
// JScript
var strXML = '<?xml version="1.0"?><test><testitem/></test>';
doc.loadXML(strXML);
MSXML3
. , async False,
. ,
,
, True.
. ,
, . 771.
.
XML. validateOnParse
True
DTD.
' VBScript Visual Basic
doc.ValidateOnParse = True
// JScript
doc.validateOnParse = true;
,
,
, parseError,
DOMDocument. parseError ,
:
errorCode
filepos
, , .
XSLT
769
line
, .
linepos
, , .
reason
srcText
, .
url
URL .
errorCode, ,
. ,
. ,
.
VBScript Visual Basic:
',
If doc.parseError.errorCode <> 0 Then '
Dim strError
strError = " XML!" & vbCrlf _
& "URL : " & doc.parseError.url & vbCrlf _
& " : " & doc.parseError.line & vbCrlf _
& ": " & doc.parseError.linepos & vbCrlf _
& " : " & doc.parseError.filepos & vbCrlf _
& " : " & doc.parseError.srcText & vbCrlf _
& " : " & doc.parseError.errorCode & vbCrlf _
& ": " & doc.parseError.reason
MsgBox strError '
Else
'
...
End If
JScript:
...
// ,
if (doc.parseError.errorCode != 0) { //
var strError = new String;
strError = 'I XML!\n'
+ 'URL : ' + doc.parseError.url + '\n '
+ ' : ' + doc.parseError.line + '\n '
+ ': ' + doc.parseError.linepos + '\n '
+ ' : ' + doc.parseError.filepos + '\n '
+ ' : ' + doc.parseError.srcText + '\n '
+ ' : ' + doc.parseError.errorCode + '\n '
+ ': ' + doc.parseError.reason;
alert(strError); //
}
else {
//
...
}
770
. Microsoft MSXML3
;
, ,
:
. .6. XML,
validateOnParse True
XML DTD XML,
( ,
, ).
, MsgBox (VB
Script):
. .7. ,
DTD XMLc
. , ,
, XML ,
, :
. .8.
XSLT
771
, . ,
,
.
, async true
, :
JScript:
var doc;
function loadDocument() {
doc = new ActiveXObject('MSXML2.DOMDocument.3.0');
doc.onDataAvailable = processDocument;
doc.async = true;
doc.load("source.xml");
}
, processDocu
ment(). , , :
function processDocument() {
if (doc.parseError.errorCode != 0) {
showError();
} else {
transformDocument();
}
}
, ,
, .
,
, ,
, .
onDataAvailable
readyState .
4 (),
.
,
, .
transform(),
true;
readyState IXSLProcessor.
772
. Microsoft MSXML3
XSLT XML
MSXML3, XML
. XSLT XMLc,
XML. DOMDocu
ment XML ,
,
transformNode() transformNodeToObject(), .
XML <?xmlstylesheet?>.
,
.
transformNode
, , ,
.
strResult = objXMLNode.transformNode(objStylesheet)
:
var objResults = document.all['divResults'];
objResults.innerHTML = objXML.transformNode(objXSL);
XSLT
773
10;
msxml_transform\default.htm.
XSL ,
.
Not XML Document.
.
transformNodeToObject
,
, DOM Document Stream:
objXMLNode.transformNodeToObject(objStylesheet, objOutput)
objXMLNode DOM:
Document Node XML (
XML
).
objStylesheet DOM,
Document, XSLT,
Node, XSLT.
objOutput , , DOM Document,
.
XML. Document
.
,
DOM Document, XSLT , ,
, <xsl:output> .
save
xml DOM, DOM
, , .
: JScript
, ,
XML JScript
Internet Explorer 5 .
msxml_transform.
HTML .
,
.
XML.
774
. Microsoft MSXML3
XML
XML
tables_data.xml. ( ,
). :
<>
<>
<>Conference</>
<>4</>
< =""></>
<></>
< ="USD">1485</>
</>
...
</>
, tables_list.xsl tables_cata
log.xsl.
JScript , XSLT
, .
HTML
HTML default.htm
, JScript, XML XSL
, ,
. , transformFiles
, :
<html>
<head>
<style type="text/css">
body {fontfamily:Tahoma,Verdana,Arial,sansserif; fontsize:14px}
.head {fontfamily:Tahoma,Verdana,Arial,sansserif;
fontsize:18px; fontweight:bold}
</style>
<script language="JScript">
function transformFiles(strStylesheetName) {
// DIV
var objResults = document.all['divResults'];
//
var objXML = new ActiveXObject('MSXML2.DOMDocument.3.0');
var objXSL = new ActiveXObject('MSXML2.DOMDocument.3.0');
//
objXML.validateOnParse = true;
objXSL.validateOnParse = true;
// XML ,
XSLT
775
objXML.load('tables_data.xml');
if (objXML.parseError.errorCode != 0) {
// ,
objResults.innerHTML = showError(objXML)
return false;
}
// XSL ,
objXSL.load(strStylesheetName);
if (objXSL.parseError.errorCode != 0) {
// ,
objResults.innerHTML = showError(objXSL)
return false;
}
//
strResult = objXML.transformNode(objXSL);
// DIV
objResults.innerHTML = strResult;
return true;
}
tables_data.xml ,
strStylesheetName .
<div>, id
divResults. , HTML
.
load ,
, ,
showError.
, ,
.
:
function showError(objDocument) {
//
var strError = new String;
strError = ' XML!<BR />'
+ 'URL : ' + objDocument.parseError.url + '<BR />'
+ ' : ' + objDocument.parseError.line + '<BR />'
+ ': ' + objDocument.parseError.linepos + '<BR />'
+ ' : ' + objDocument.parseError.filepos + '<BR />'
+ ' : ' + objDocument.parseError.srcText + '<BR />'
+ ' : ' + objDocument.parseError.errorCode + '<BR />'
+ ': ' + objDocument.parseError.reason
return strError;
}
//>
</script>
776
. Microsoft MSXML3
HTML, .
<body> onload,
transformFiles()
:
...
</head>
<body onload="transformFiles('tables_list.xsl')">
<p><span class="head"> XML
</span></p>
...
tables_list.xsl,
. .
HTML <but
ton> . onclick
transformFiles()
:
...
<button onclick="transformFiles('tables_catalog.xsl')"></button>
<button onclick="transformFiles('tables_list.xsl')"> </button>
<hr />
, <div>,
.
<! >
<div id="divResults"></div>
</body>
</html>
HTML :
. .9. HTML,
XML JScript
XSLT
777
,
,
.
XSLTemplate
Document
XML ,
transformNode HTML.
,
, ,
. ,
,
XSLTemplate.
.
10,
, , XML
.
, XSLTemplate
stylesheet DOM (
), <xsl:stylesheet>:
objStyle = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
objStyle.async = false;
objStyle.load('stylesheet.xsl');
objTemplates = new ActiveXObject("MSXML2.XSLTemplate");
objTemplates.stylesheet = objStyle.documentElement;
XSLTemplate ,
.
XSLProcessor,
, .
,
XML. XSLProcessor
, XSLTemplate :
var objTransformer = objTemplates.createProcessor();
XSLProcessor,
(
<xsl:param>
), transform().
output XSLProcessor:
objTransformer.input = source;
objTransformer.addParameter("1", "1", "");
778
. Microsoft MSXML3
addParameter() URI
. .
<object>
XML
MSXML Document
<object> HTML.
XML HTML <xml>.
<object>, <xml> HTML, XML.
<object>
MSXML Document HTML
<object>, ClassID ,
.
, MSXML 3.0,
async validateOnParse false:
<object id="XMLDocument" width="0" height="0"
classid="clsid:f5078f32c55111d389b90000f81fe221">
<param name="async" value="false">
<param name="validateOnParse" value="false">
</object>
<object id="XSLDocument" width="0" height="0"
classid="clsid:f5078f32c55111d389b90000f81fe221">
<param name="async" value="false">
<param name="validateOnParse" value="false">
</object>
,
, , Document
:
// XML
var objXML = document.all['XMLDocument'];
// XSL
var objXSL = document.all['XSLDocument'];
// XML ,
objXML.load('tables_data.xml');
if (objXML.parseError.errorCode != 0) {
//
<object> XML
779
objResults.innerHTML = showError(objXML)
return false;
}
// ,
objXSL.load(strStylesheetName);
if (objXSL.parseError.errorCode != 0) {
//
objResults.innerHTML = showError(objXSL)
return false;
}
//
strResult = objXML.transformNode(objXSL);
XML
Internet Explorer 5 HTML <xml>,
XML HTML
(data island).
MSXML . , <xml>
HTML, XML. HTML
, XML,
XSL:
<xml id="" src="tables_data.xml"></xml>
<xml id=" " src="tables_list.xsl"></xml>
,
:
function transformFiles() {
// DIV
var objResults = document.all['divResults'];
// XML
var objXML = document.all['Source'].XMLDocument;
// XSL
var objXSL = document.all['Stylesheet'].XMLDocument;
//
strResult = objXML.transformNode(objXSL);
// DIV
objResults.innerHTML = strResult;
}
, ,
XMLDocument . DOMDocument,
<object>,
, <xml>,
XML. HTML,
780
. Microsoft MSXML3
XML XMLDocument
<xml>.
<xml>
Document, ,
src <xml>.
src :
// XSL
var objDI = document.all['XSLParser'];
objDI.src = 'tables_list.xsl';
var objXSL = objDI.XMLDocument;
, , .
, , ,
<script>,
<xml>:
<script language="XML" src="tables_data.xml"></script>
XML
XML XSLT,
MSXML
(W3C Document Object Model, DOM)
Microsoft.
XML
.
, , XML,
. DOM
XML
. , XML
, XSLT, ,
,
.
Document XML, ,
DOM .
XML .
,
,
; XSLT
, .
XML5
781
XSLT
,
, .
.
, <xsl:sort>
. , ,
, .
, ,
! , , ,
DOM ,
.
,
XML XSLT,
HTML. , ,
.
:
msxml_dynamic.
XML
XML tables.da
ta.xml. <table>,
:
<>
<>
<>Conference</>
<>4</>
< =""></>
<></>
< ="USD">1485</>
</>
...
</>
tables_list.xsl.
;
JScript ,
XSLT, .
<xsl:applytemplates>,
:
<xsl:template match="/">
782
. Microsoft MSXML3
<html>
. . .
<xsl:applytemplates select="//">
<xsl:sort select="" order="ascending"/>
</xsl:applytemplates>
. . .
</html>
</xsl:template>
HTML
<xsl:sort>, ,
.
HTML
HTML,
. default.htm.
onload <body> if (preparePage())
sort('tablename', 'ascending'). HTML
preparePage().
( ),
sort(), ,
.
. . .
<body onload="if (preparePage()) sort('', 'ascending')">
<p><span class="head"> XML
</span></p>
HTML ,
. ,
sort,
.
select order <xsl:sort> .
:
<button onclick="sort('', 'ascending')"></button>
<button onclick="sort('', 'ascending')"></button>
<button onclick="sort('', 'ascending')">. </button>
<button onclick="sort('/@',
'ascending')"></button>
<button onclick="sort('', 'ascending')"></button>
<button onclick="sort('', 'ascending')"> +</button>
<button onclick="sort('', 'descending')"> </button>
<hr/>
HTML ,
, HTML:
<object id="XMLDocument" width="0" height="0"
classid="clsid:f5078f32c55111d389b90000f81fe221">
XML5
783
JScript, , .
preparePage(),
<div>
Document, XML XSL:
// ,
var gobjResults;
var gobjXML;
var gobjXSL;
function preparePage() {
// DIV
gobjResults = document.all['divResults'];
// XML
gobjXML = document.all['XMLDocument'];
// XSL
gobjXSL = document.all['XSLDocument'];
// XML ,
gobjXML.load('tables_data.xml');
if (gobjXML.parseError.errorCode != 0) {
//
gobjResults.innerHTML = showError(gobjXML)
return false;
}
// XSL ,
gobjXSL.load('tables_list.xsl');
if (gobjXSL.parseError.errorCode != 0) {
//
gobjResults.innerHTML = showError(gobjXSL)
return false;
}
//
return true;
}
784
. Microsoft MSXML3
load() ,
showError() (
, ),
. ,
, sort().
, sort(),
select order <xsl:sort>.
Document DOM,
DOM.
,
XPath.
Microsoft selectSingleNode()
XPath,
. ,
<xsl:sort>.
selectSingleNode() ,
Microsoft WDxsl, selection
Language DOMDocument XPath.
, ,
.
, sort() :
function sort(strSortBy, strOrder) {
// 'select' 'order'
// 'xsl:sort'
var objSelect = gobjXSL.selectSingleNode("//xsl:sort/@select");
var objOrder = gobjXSL.selectSingleNode("//xsl:sort/@order");
// XPath
objSelect.nodeValue = strSortBy;
objOrder.nodeValue = strOrder;
//
strResult = gobjXML.transformNode(gobjXSL);
// DIV
gobjResults.innerHTML = strResult;
}
.
,
,
(. .10).
,
,
. .11.
XPath DOM
785
. .10. HTML
. .11. HTML ;
XPath DOM
DOM
selectSingleNode(), XPath.
, MSXML
XPath XSLT.
,
XSLT.
DOM XML.
selectNodes XPath
///;
NodeList, <tablename> :
function getTableNames() {
// DIV
var objResults = document.all['divResults'];
// XML
var objXML = new ActiveXObject('MSXML2.DOMDocument.3.0');
786
. Microsoft MSXML3
// XML
objXML.load('tables_data.xml');
if (objXML.parseError.errorCode != 0) {
//
objResults.innerHTML = showError(objXML)
return false;
}
var strResult = new String; //
strResult = ' : ';
// , <>
var objTableNodeList = objXML.selectNodes('///');
<>,
( ),
, <div>
:
// <>
for (var i = 0; i < objTableNodeList.length; i++) {
//
strName = objTableNodeList(i).childNodes(0).nodeValue;
strResult += '"<b>' + strName + '</b>" ';
}
// DIV
objResults.innerHTML = strResult;
}
XML
. .12.
MSXML3
MSXML3
XSLT .
, MSXML3.
MSXML3
787
XSLT, ,
HTML, API Microsoft.
,
,
XML ,
XML HTML ,
HTML . XSLT,
, Win
dows, MSXML3.
MSXML3 COM,
, COM.
VBScript JScript,
ASP , ,
Visual Basic, C++, Java, Delphi . .
MSXML3 ASP
ASP
, .
ASP
CreateObject Server:
VBScript:
Dim objDocument
Set objDocument = Server.CreateObject("MSXML2.DOMDocument.3.0")
JScript:
var objDocument = Server.CreateObject('MSXML2.DOMDocument.3.0');
, ,
<object>, .
runat:server.
, ,
, Server.CreateObject
. , ,
( ,
Server.CreateObject).
ASP global.asa
,
,
, , . 759.
,
. , ,
, ,
Response.Write
, .
788
. Microsoft MSXML3
: XSLT
ASP
msxml_asp. XSLT
, HTML
.
XML
XML ,
.
:
<>
<>
<>Conference</>
<>4</>
< =""></>
<></>
< ="USD">1485</>
</>
tables_style.xsl .
;
, .
, HTML.
ASP
ASP. simple_transform.asp:
<%@LANGUAGE="VBScript"%>
<%
' , HTML
Response.ContentType = "text/html"
'
Sub ShowError(objDoc)
'
Dim strError
strError = " XML!<BR />" _
& "URL : " & objDoc.parseError.url & "<BR />" _
& " : " & objDoc.parseError.line & "<BR />" _
& ": " & objDoc.parseError.linepos & "<BR />" _
& " : " & objDoc.parseError.filepos & "<BR />" _
& " : " & objDoc.parseError.srcText & "<BR />" _
& " : " & objDoc.parseError.errorCode & "<BR />" _
& ": " & objDoc.parseError.reason
Response.Write strError
End Sub
Dim objXML
MSXML3
789
Dim objXSL
'
Set objXML = Server.CreateObject("MSXML2.DOMDocument.3.0")
Set objXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")
'
objXML.ValidateOnParse = True
objXSL.ValidateOnParse = True
' XML
objXML.load Server.MapPath("tables_data.xml")
If objXML.parseError.errorCode <> 0 Then
'
ShowError objXML
Response.End
End If
, XML XSLT
ASP
Server.MapPath. , load
.
' XSL
objXSL.load Server.MapPath("tables_style.xsl")
If objXSL.parseError.errorCode <> 0 Then
'
ShowError objXSL
Response.End
End If
'
strResult = objXML.transformNode(objXSL)
'
Response.Write strResult
%>
790
. Microsoft MSXML3
, , XML XSLT
. , <FORM>
HTML, ,
"stylesheet_name". ASP
load:
objXSL.load Server.MapPath(Request.Form("stylesheet_name"))
,
ASP:
Response.ContentType = "text/html"
HTTP,
, HTML. ,
HTML
. , ,
,
text/html, .
MIME
Response.ContentType.
, HTML.
, XSLT ASP
XML, :
Response.ContentType = "text/xml"
XSLT, ,
text/xml. Internet Explorer text/
xsl, , MIME,
.
text/plain. , (, ,
, ) ,
, , .
, ,
, , .
Internet Explorer MIME
HTTP. , URL: ,
, .html, HTML
, .xml, XML.
, , URL:
http://www.company.com/transform.asp?style=my.xsl&source=my.xml
, XML,
HTTP text/html.
MSXML3
791
.xml URL.
&x=y .
ASP ,
, URL. ,
URL:
http://www.company.com/transform.asp?employee=517541
,
employee 517541. ,
.
,
transformNode() DOMDocument.
: XSLTemplate,
;
XSLTProcessor, createProcessor() XSLTemplate
addParameter() XSLTProcessor
. :
strResult = objXML.transformNode(objXSL)
:
Dim templates
Dim transformer
templates = Server.CreateObject("MSXML2.XSLTemplate")
templates.stylesheet = objXSL.documentElement
transformer = templates.createProcessor()
transformer.input = objXML
transformer.addParameter("employee", Request.QueryString("employee"), "")
strResult = transformer.transform()
ASP.
XSLTemplate
.
XSLTemplate,
global.asa. ,
DOMDocument.
ASP
:
HTML,
ASP.
& , , URL:
792
. Microsoft MSXML3
http://www.company.com/transform.asp?emp=517541&loc=bracknell,
, XSLT
, XSLT
, ,
,
, .
ASP,
( HTTP, )
. Mic
rosoft ISAPI ,
. XSLT,
, ,
MSXML3.
blnIsIE5
True, Internet Explorer 5
:
blnIsIE5 = False
strUA = Request.ServerVariables("HTTP_USER_AGENT")
If InStr(strUA, "MSIE") Then
intVersion = CInt(Mid(strUA, InStr(strUA, "MSIE") + 5, 1))
If intVersion > 4 Then blnIsIE5 = True ' IE5
End If
,
MSXML3 .
, :
XSLT WDxsl, HTML,
,
.
JScript
. 773. , ,
, , ,
, , (Jarno Elovir
ta) msxmlversion.html.
, !
:
MSXML3,
. ,
MSXML3
793
:
,
cookie.
, :
, .
,
XML ;
10 ,
<xsl:import>.
XML (,
), <?xml
stylesheet?>. ,
HTML, .
, <?xmlstylesheet?> .
XML <?xml
stylesheet?> .
,
:
. HTML
.
,
,
: ,
:
. .14. ,
794
. Microsoft MSXML3
Internet Explorer 5
XML, <xsl:stylesheet>,
XSLT
. HTML
, .
:
XML,
10,
,
.
, .
,
,
. XML ,
, .
.
,
FileSystemObject:
...
'
strResult = objXML.transformNode(objXSL)
'
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("resultpage.htm", True)
'
objFile.Write strResult
objFile.Close
XSLTransform Sto
neBroom,
.
http://www.stonebroom.com.
MSXML3
, , , MSXML3,
, SDK.
SDK .
MSXML3
795
,
XSLT XPath.
, , (
) ,
, .
Microsoft DOM ( ,
MSXML3) Wrox XML
(Professional XML ISBN 1861003110).
, XSLT
XPath, :
IXMLDOMDocument
XML
IXMLDOMNode
DOM
IXMLDOMNodeList
Node
IXMLDOMParseError
,
IXMLDOMSelection
IXSLProcessor
XSLT
IXSLTemplate
XSLT
IXMLDOMDocument IXMLDOMDocument2
IXMLDOMDocument IXMLDOMNode.
IXMLDOMDocument2 ,
.
,
XSLT XPath, , ,
IXMLDOMNode, . 799.
,
XPath XSLT.
validate() setProperty() IXMLDOMDocument2,
IXMLDOMDocument,
MSXML2.
796
. Microsoft MSXML3
abort
()
load
Boolean
XML
loadXML
Boolean
save
()
setProperty ()
()
DTD
validate
abort() ( )
,
abort(), .
load(URL)
, , URL URL
XML.
Docu
ment XML
URL. ,
True, False.
, , URL, ../
article.xml; HTML,
URL URL .
, , URL,
mapPath().
loadXML()
XML.
Document
XML. ,
True, False.
save( ) ( )
,
. XML
. ,
Document,
. Response.
MSXML3
797
setProperty(, ) ( )
,
,
selectNodes() selectSingleNode().
getProperty(). :
SelectionLanguage. XPath XSLPattern.
XSLPattern.
, selectNodes() selectSingleNode().
XPath 1.0
XPath.
XSLPattern Microsoft WDxsl.
SelectionNamespaces.
, , :
xmlns:a='http://companya.com/' xmlns:b='http://companyb.com/'
,
,
selectNodes() selectSingleNode().
ServerHTTPRequest. True
False; False.
True ,
.
True, async False.
,
MSXML3
. :
intranet, WinHTTP.
,
.
SDK.
validate() ( )
, ,
DTD .
, ,
.
. , ,
, XSLT
.
JScript :
try {
xmldoc.validate();
} catch(e) {
alert(" : " + e.description);
}
798
. Microsoft MSXML3
async
Boolean
True
parseError
IXMLDOMParseError
readyState
Long
validateOnParse
Boolean
async
(True),
,
. async
False,
, load() .
parseError IXMLDomParseError
IXMLDOMParseError. ,
, ,
errorCode .
readyState
:
0
UNINITIALIZED
load()
LOADING
load()
LOADED
INTERACTIVE
,
DOM
COMPLETED
,
, onReadyStateChange, ,
COMPLETED
onDataAvailable.
799
MSXML3
validateOnParse
True,
DTD .
IXMLDOMNode
. ,
DOM,
XPath, 2; , ,
,
.
IXMLDOMNode.
,
XSLT XPath.
, , IXMLDOMDocument,
,
.
IXMLDOMNode,
XSLT XPath.
( DOM Document), , ,
.
selectNodes
IXMLDOMNodeList
selectSingleNode IXMLDOMNode
XPath
XPath
transformNode
String
,
,
transformNode
ToObject
()
,
selectNodes( ) IXMLDOMNodeList
XPath,
,
.
800
. Microsoft MSXML3
XPath 1.0,
Microsoft WDxsl, selectionLanguage
XPath.
,
XPath ,
child, .
Microsoft .
, XPath ,
, ,
.
, selectionNamespaces DOMDocument.
, .
,
.
IXMLDOMDocument2,
IXMLDOMDocument,
IXMLDOMNodeList IXMLDOMSelection.
selectSingleNode( ) IXMLDOMNode
selectNodes(), ,
,
.
selectNodes(),
XPath 1.0 Microsoft WDxsl,
selectionLanguage XPath.
, .
transformNode( IXMLDOMNode)
,
.
( ,
),
.
XSLT. , Docu
ment, Node,
, Document.
.
BSTR,
, <xsl:output>.
transformNodeToObject( IXMLDOMNode,
Variant) ( )
,
.
, .
MSXML3
801
XSLT. ,
Document, Node,
, Document.
,
. Document, Stream.
. ,
,
, XPath.
baseName
String
namespaceURI
String
URI
nodeName
String
,
. ,
XPath,
, "#document", "#text" "#comment"
nodeTypeString String
.
"element", "attribute" "comment"
nodeValue
Variant
, . ,
XPath; ,
null
prefix
String
,
text
String
, (
XPath)
xml
String
XML
IXMLDOMNodeList
.
, selectNodes().
IXMLDOMNodeList selectNodes().
, XPath.
, nextNode(),
item.
, .
, ,
IXMLDOMDocument2, MSXML2,
selectNodes()
IXMLDOMSelection, . 803.
802
. Microsoft MSXML3
item
IXMLDOMNode
nextNode
IXMLDOMNode
reset
()
item( ) IXMLDOMNode
. ,
, n NodeList nodes,
nodes[n].
nextNode() IXMLDOMNode
,
.
reset() ( )
,
.
length
Long
IXMLDOMParseError
parseError IXMLDOMDocument.
, ,
. 768.
errorCode
Long
filepos
Long
, XML
line
Long
linepos
Long
reason
String
srcText
String
XML,
url
String
URL ,
803
MSXML3
IXMLDOMSelection
.
selectNodes(),
IXMLDOMDocument2.
,
.
(view) : ,
.
IXMLDOMNodeList.
clone
IXMLDOMSelection
IXMLDOMSelection
getProperty String
item
IXMLDOMNode
matches
IXMLDOMNode
,
nextNode
IXMLDOMNode
reset
()
clone() IXMLDOMSelection
IXMLDOMSelection.
getProperty( )
. ,
, SelectionLanguage,
IXMLDOMDocument.
item( ) IXMLDOMNode
. ,
, n NodeList nodes,
nodes[n].
matches(IXMLDOMNode )
, ,
. (
XPath ,
XSLT.)
nextNode() IXMLDOMNode
,
.
804
. Microsoft MSXML3
reset() ( )
, ,
nextNode(), .
expr
String
XPath, ,
. ,
context
IXMLDOMNode
.
length
Long
IXSLProcessor
IXSLProcessor
.
, , createProcessor()
IXSLTemplate.
transform().
addParameter ()
<xsl:param>
()
setStartMode ()
XSLT
reset
transform
Boolean
XSLT
MSXML3
805
.
, , Node
NodeList.
. (
Document
XSLT document(), ,
.)
reset() ( )
,
,
. ,
startMode.
setStartMode( , namespaceURI)
( )
,
,
mode.
, MSXML3
, .
4: . <xsl:applytemplates>
<xsl:template>.
,
, URI
. .
transform() Boolean
( XSLProcessor)
, input.
output.
, True.
, transform()
False, , ,
.
, transform() .
readyState.
input
Variant
XML,
. ,
DOM Document, Node
IStream.
806
. Microsoft MSXML3
output
Variant
.
,
,
.
, DOM
Document, DOM Node IStream.
Long
.
READYSTATE_COMPLETE (3).
startMode
String
XSLT. .
setStartMode() .
startModeURI String
XSLT. .
setStartMode() .
stylesheet
IXMLDOMNode
IXSLTemplate
IXSLTemplate
, .
, IXSLTemplate
,
transformNode().
createProcessor
IXSLProcessor
IXSLProcessor
createProcessor() IXSLProcessor
,
stylesheet IXSLTemplate.
IXSLProcessor,
.
stylesheet
IXMLDOMNode
,
IXSLTemplate
; IXSLTemplate
, .
807
, MSXML3
Microsoft, , XSLT
.
, XML
IE5 , ,
<?xmlstylesheet?>.
,
. , ,
.
MSXML3
, , ASP,
,
.
,
Microsoft API XSLT.
Microsoft ,
. ,
, Internet Explorer WD
xsl, . ,
, Microsoft
XSL WDxsl,
XSLT 1.0 ( XSLT 1.1).
MSXML3 , ,
XSLT.
( Netscape
, ),
XSLT .
,
,
,
.
B
Oracle
XML Oracle
XML (XML Developer's Kit, XDK) Oracle.
, .
XML Oracle Java;
Oracle C++. , ,
XSLT .
XDK,
XSLT. ,
Oracle. Oracle
XML ,
,
,
.
XML Oracle, , ,
, ,
Oracle.
XML Oracle
XDK Wrox
Press Oracle 8i (Professi
onal Oracle 8i Application Programming, ISBN 1861004842).
,
, .
Oracle,
XML http://technet.oracle.com/tech/xml.
XML Oracle
809
,
. ,
,
:
, (
, ,
).
, .
XML
Oracle
XML W3C,
810
B. Oracle
. XML DTD,
.
,
API: Java XML,
. ,
( xschema.jar)
CLASSPATH, .
XSQL
XDK,
W3C, XSQL Oracle.
, ,
SQL XML.
XSQL XML,
SQL. :
<?xml version 1.0?>
<xsql:query xmlns="urn:oraclexsql" connection="productdb">
SELECT description FROM product WHERE code='PZ662431'
</xsql:query>
(productdb) ,
.
XSQL ASP JSP.
,
URL ,
,
. XSQL ,
, , ,
XSQL , API
. WebtoGo,
Windows 2000.
,
XML:
<?xml version="1.0"?>
<ROWSET>
<ROW num="1">
<description>Highspeed electric drill</description>
</ROW>
</ROWSET>
, ,
XML Oracle
811
,
.
XSQL ,
URL, , URL :
http://www.megacorp.com/xsql/catalog.xsql?prodcode=PZ87453
SQL :
<xsql:query xmlns="urn:oraclexsql" connection="productdb">
SELECT description FROM product WHERE code='{@prodcode}'
</xsql:query>
, , XML HTML
XSLT.
XSQL <?xmlstylesheet?>.
,
(
). :
<?xml version 1.0?>
<?xmlstylesheet type="text/xsl" media="Mozilla" href="navigator.xsl"?>
<?xmlstylesheet type="text/xsl" media="Spyglass" href="mosaic.xsl"?>
<?xmlstylesheet type="text/xsl" href="default.xsl"?>
<xsql:query xmlns="urn:oraclexsql" connection="productdb">
SELECT description FROM product WHERE code='{@prodcode}'
</xsql:query>
URL. ,
: . , URL
( )
iexplorer.xsl :
http://www.megacorp.com/xsql/catalog.xsql?prodcode=PZ87453&
xmlstylesheet=iexplorer&transform=client
, URL HTML
XSLT, & &. HTML
&, ,
XML .
812
B. Oracle
Java
OracnsleXMLQuery, XML SQL,
OracleXMLSave, :
XML.
Oracle
XML: ,
, SELECT * FROM
products XSQL In
ternet Explorer, . ,
: <ROWSET> , <ROW>
, , SQL
.
,
, ,
XSLT.
, XML
OracleXMLQuery, ,
.
XML
OracleXMLSave.
XML
Oracle XML SQL
XML,
Oracle XML
Java C++.
DTD,
XML. DTD,
, Java ++
DTD.
Java C++
(,
Customer (), Account () Invoice ()),
, Element, Attribute
Document, DOM.
, Oracle,
, ,
XML, ,
.
,
, XSLT!
XSLT5, Java
813
XSLT, Java
XSLT Oracle
XML. http://technet.oracle.com/tech/
xml/. XSLT Java XML: Parser for Ja
va v2.
, ,
. 2001 ,
Oracle 9i, Oracle.
,
. ,
, Oracle
. , ,
( , (Steve Mu
ench)) .
XSLT Oracle XML,
DOM SAX,
XML.
, . , 2.0,
DOM 1.0 SAX 1.0. , 2.1,
DOM 2.0 SAX 2.0.
Oracle , XSLT
( 1999 ) XSLT 1.0 XPath 1.0.
,
,
.
Oracle , ,
,
. ,
:
,
, .
API javadoc
. , ,
.
XSLT Oracle
. Java
Oracle,
PATH CLASSPATH,
:
java oracle.xml.parser.v2.oraxsl source.xml stylesheet.xsl result.xml
814
B. Oracle
d directory
, ,
e errorlog
i sourceextension
l xmlfilelist
o directory
p parameterlist
, =
(. )
r resultextension
s stylesheet
t numberofthreads
v
w
x sourceextension
p.
, ,
, (
,
10, d3):
java oracle.xml.parser.v2.oraxsl p start='d3' dummy.xml tour10.xsl out.html
,
.
, Java
API. , .
API
XSLT Oracle TrAX API,
F, JAXP 1.1,
(Steve Muench)
,
, Oracle 9i.
XSLT5, Java
815
: ,
API, Oracle.
XSLT, API TrAX
,
Oracle API.
API
javadoc ,
.
XSLStylesheet,
( ) ,
, XSLProcessor,
. XSLStylesheet
Templates TrAX,
XSLProcessor TrAX Transformer.
XSLStylesheet.
.
, URL,
URI URI,
<xsl:include> <xsl:import>.
:
XMLDocument ( DOM,
Oracle)
URL,
InputStream,
Reader,
XSLStylesheet
. ,
.
. XSLProcessor.
( . ,
, XSLStylesheet,
XSLProcessor. ,
, .)
XSLProcessor :
.
processXSL(), :
816
B. Oracle
XMLDocumentFragment
processXSL(
XSLStylesheet xsl,
java.io.InputStream xml,
java.net.URL baseURI)
XML
.
InputStream,
URI
URI .
DOM DocumentFragment.
XMLDocumentFragment processXSL(
XSLStylesheet xsl,
java.io.Reader xml,
java.net.URL baseURI)
XML
.
Reader,
URI URI
.
DOM DocumentFragment.
XMLDocumentFragment processXSL(
XSLStylesheet xsl,
java.net.URL xml,
java.net.URL baseURI)
XML
. URL
,
URI
URI .
DOM
DocumentFragment.
XML
.
DOM.
SAX2
ContentHandler.
XML
.
DOM DocumentFragment.
OutputStream.
void
processXSL(
XSLStylesheet xsl,
XMLDocumentFragment xml,
java.io.PrintWriter pw)
XML
.
DOM DocumentFragment.
PrintWriter.
XSLT5, Java
817
void
processXSL(
XSLStylesheet xsl,
XMLDocumentFragment inp,
XMLDocumentHandler handler)
XML
.
DOM DocumentFragment.
SAX1 DocumentHandler.
void
processXSL(
XSLStylesheet xsl,
XMLDocument xml,
java.io.OutputStream os)
XML
.
DOM Document.
OutputStream.
void
processXSL(
XSLStylesheet xsl,
XMLDocument xml,
java.io.PrintWriter pw)
XML
.
DOM Document.
PrintWriter.
void
processXSL(
XSLStylesheet xsl,
XMLDocument xml,
XMLDocumentHandler handler)
XML
.
DOM Document.
SAX1
DocumentHandler.
, Oracle XSLT
DOM Document DocumentFragment,
Document DocumentFragment,
Oracle.
.
//
parser = new DOMParser();
parser.setPreserveWhitespace(true);
// XSLT DOM
xslURL = createURL(args[0]);
parser.parse(xslURL);
xsldoc = parser.getDocument();
// XML DOM
xmlURL = createURL(args[1]);
parser.parse(xmlURL);
xmldoc = parser.getDocument();
//
XSLStylesheet xsl = new XSLStylesheet(xsldoc, xslURL);
// XSL
XSLProcessor processor = new XSLProcessor();
processor.showWarnings(true);
processor.setErrorStream(System.err);
//
818
B. Oracle
DocumentFragment result = processor.processXSL(xsl, xmldoc);
// ,
//
out = new XMLDocument();
//
//
Element root = out.createElement("root");
out.appendChild(root);
//
//
root.appendChild(result);
//
out.print(System.out);
transformNode() XMLNode ( org.w3c.dom.Node Orac
le). XSLStylesheet
DocumentFragment.
Oracle XSLT 1.0:
.
;
,
readme.
oracle:nodeset()
, nodeset()
XSLT 1.0:
,
, .
,
, :
,
.
XSLT 1.1,
.
,
URI : http://
www.oracle.com/XSL/Transform/java.
XSLT5, Java
819
: oracle:nodeset()
,
oracle:nodeset(). ,
.
. (, ,
.)
oraclenodeset.xsl:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:variable name="">
<table><tr><td val="85"/></tr></table>
</xsl:variable>
<xsl:variable name="ns" select="oracle:nodeset($)"
xmlns:oracle="http://www.oracle.com/XSL/Transform/java"/>
<><xsl:valueof select="$ns//td/@val"/></>
</xsl:template>
</xsl:stylesheet>
:
<?xml version = '1.0' encoding = 'UTF8'?>
<>85</>
oracle:output
. , <xsl:document>,
XSLT 1.1.
Oracle :
( ),
, ,
.
<oracle:output>, <oracle:output> use,
name <oracle:output>
. ,
<xsl:output>, , .
href <oracle:output>.
820
B. Oracle
.
, <xsl:document> , 4,
,
Oracle.
: oracle:output
,
oracle:output ,
.
.xml (,
, ).
<>, , ,
<>.
oraclesplit.xsl.
,
.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:oracle="http://www.oracle.com/XSL/Transform/java"
extensionelementprefixes="oracle">
<xsl:template match="">
<>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:applytemplates select=""/>
</>
</xsl:template>
<xsl:template match="">
<xsl:variable name=""
select="concat('', position(), '.xml')"/>
< ="{position()}" href="{$}"/>
<oracle:output href="{$}" use="">
<xsl:copyof select="."/>
</oracle:output>
</xsl:template>
<oracle:output name="" method="xml" encoding="iso88591"/>
</xsl:stylesheet>
XSLT5, Java
821
(
):
<?xml version = '1.0' encoding = 'UTF8'?>
< xmlns:oracle="http://www.oracle.com/XSL/Transform/java">
<>Song</>
<> </>
<>1912</>
< ="1" href="1.xml"/>
< ="2" href="2.xml"/>
< ="3" href="3.xml"/>
</>
; ,
, 1.xml :
<?xml version = '1.0' encoding = 'iso88591'?>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
, , Java java.util.Date,
:
xmlns:Date="http://www.oracle.com/XSL/Transform/java/java.util.Date"
, XPath,
, , new
.
XPath ,
Java.
822
B. Oracle
Java,
XPath,
.
XPath
.
( ) XPath
,
Java: Java,
.
XPath
Java.
:
Java
XPath
java.lang.String
boolean
org.w3c.dom.NodeList
(. )
org.w3c.dom.DocumentFragment
: XMLNodeList,
Oracle; XMLNodeList
, .
DOM NodeList, .
, XMLDocumentFragment,
DOM DocumentFragment.
,
XPath. ,
String, ,
XPath string().
.
(
), .
( )
, ,
. ,
java.lang.Math max(),
, max(int, int), max(double, double), max(long, long)
max(float, float).
, , .
Java.
XSLT 1.0 (,
XSLT5, Java
823
, , ),
;
.
0.0 1.0. ja
va.lang.Math.
<xsl:variable name="random" select="Math:random()"
xmlns:Math=="http://www.oracle.com/XSL/Transform/java/java.lang.Math"/>
, ,
Java .
java.util.Date. Date
XPath .
, toString() java.util.Date,
, .
,
.
<xsl:valueof select="Date:toString(Date:new())"
xmlns:Date="http://www.oracle.com/XSL/Transform/java/java.util.Date"/>
, , , ,
oracle:nodeset().
oracle:nodeset(),
, : children()
, .
Java,
OracleChildren.java. , :
import org.w3c.dom.*;
public class OracleChildren {
public static NodeList children(DocumentFragment tree) {
return tree.getChildNodes();
}
}
, ,
oraclechildren.xsl.
, OracleChildren
CLASSPATH. <>85</>:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:variable name="">
<table><tr><td val="85"/></tr></table>
</xsl:variable>
<xsl:variable name="ns" select="my:children($)"
824
B. Oracle
xmlns:my="http://www.oracle.com/XSL/Transform/java/OracleChildren"/>
<><xsl:valueof select="$ns//td/@val"/></>
</xsl:template>
</xsl:stylesheet>
XPath
javadoc
, , XMLNode,
org.w3c.dom.Node,
DOM XPath,
XSLT.
:
selectNodes(
String expression)
,
DOM NodeList
selectNodes(
,
String expression,
NSResolver
NSResolver resolver) , DOM NodeList
selectSingleNode(
String expression)
,
DOM Node
selectSingleNode(
,
String expression,
NSResolver
NSResolver resolver) , DOM Node
NSResolver ,
URI. ,
XMLElement XMLDocument ( DOM Element Document Oracle)
NSResolver.
,
, javadoc ,
, . ,
XSL, ,
. ;
"",
<>, . ,
<>,
( ,
). ,
XPath, ,
Microsoft.
, XPath,
, XSLException,
, .
XSLT5, Java
825
(, ,
Wrox Professional Oracle 8i Application
Programming) selectNodes(),
XPath .
.
( ,
) .
import
import
import
import
java.io.*;
oracle.xml.parser.v2.*;
org.xml.sax.*;
org.w3c.dom.*;
826
B. Oracle
File file = new File(filename);
FileReader reader = new FileReader(file);
DOMParser parser = new DOMParser();
parser.parse(reader);
return parser.getDocument();
}
public static void main(String[] args) {
if (args.length == 1)
new XPathToy(args[0]);
else
System.err.println(": java XPathToy <_>");
}
} // XPathToy
,
CLASSPATH , XPathToy,
xmlparserv2.jar, :
java XPathToy poem.xml
XPath. , ,
:
XPath>//[1]/[2]/()
:
: #text
: And Spring is here again;
, quit.
, ,
DOM getNodeName() getValue().
XPath,
. ,
text() XPath, .
Oracle
, :
BIG 5
ISO2022KR
EBCDICCP*
ISO88591 ISO88599
EUCJP
KOI8R
EUCKR
Shift_JIS
827
GB2312
USASCII
ISO10646UCS2
UTF16
ISO10646UCS4
UTF8
ISO2022JP
, ASCII
EBCDIC, Java.
Java ,
,
IANA.1
, ,
XSLT, Oracle,
. , ,
,
, .
, Oracle
. ,
, ,
.
Oracle,
XSQL Pages
,
. XSLT
, , , ,
,
.
C
Saxon
Saxon, XSLT c .
(Michael Kay).
ICL, IT, Software
AG, , , , , .
Saxon http://users.iclway.co.uk/mhkay/saxon/.
Mozilla Public License,
, ,
. ,
.
, http://saxon.xsl.
listbot.com/, .
Java Java 1.1 Java 2.
: Saxon,
Java, ,
API ; Instant Saxon,
Windows.
.
, 6.2,
W3C XSLT 1.0 XPath 1.0,
XSLT 1.1 5 2000 .
,
( XSLT
,
). .
829
Saxon
Saxon Java TrAX
API, JAXP 1.1, F.
Java.
. , Saxon
, ,
URL,
, .
; Saxon
, XML Spy (http://www.
xmlspy.com), .
830
C. Saxon
Saxon
Windows
API, ,
Instant Saxon,
, Java
Microsoft.
:
saxon source.xml style.xsl >output.html
MSDOS Windows,
,
.
,
. : Program
mer's File Editor UltraEdit.
, saxon.exe,
PATH, ,
C:\saxondir\saxon.
Saxon
Java. :
java com.icl.saxon.StyleSheet source.xml style.xsl >output.html
Java Sun,
jview com.icl.saxon.StyleSheet source.xml style.xsl >output.html
Microsoft JVM.
Sun JDK 1.3 , Microsoft JVM,
Instant Saxon ( Microsoft
JVM) , .
,
. Instant Saxon
saxon :
saxon t w2 source.xml style.xsl >out.html
Saxon , :
java com.icl.saxon.StyleSheet t w2 source.xml style.xsl >out.html
a
<?xmlstylesheet?>
.
, , .
Saxon
831
ds
dt
. dt
(tinytree model) ( ). ds
.
: ,
, .
dt.
l
.
saxon:linenumber()
. ,
T.
m classname Java,
<xsl:message>, .
Saxon com.icl.saxon.output.Emitter,
SAX2 ContentHandler.
, <xsl:message> Sys
tem.err.
o filename
,
. ,
:
, ,
a. ,
System.out (
>_).
r classname Java,
URI, document()
<xsl:include> <xsl:import>.
URI,
.
TrAX javax.xml.transform.URIResolver.
t
Saxon Java,
, .
T
.
,
. System.err.
XML,
!
TL
classname
. ,
com.icl.saxon.trace.TraceListener.
,
tbug, (Edwin
Glaser) http://tbug.sourceforge.net.
832
C. Saxon
u
, ,
, URL,
. ( http: file:,
.)
w0
,
, Saxon
, XSLT,
. , ,
,
.
w1
,
Saxon
, XSLT,
. , ,
,
,
.
w2
, Saxon
, ,
.
x classname XML,
, docu
ment(). classname ,
SAX1
org.xml.sax.Parser
SAX2
org.xml.sax.XMLReader.
y classname XML,
,
<xsl:include> <xsl:import>. classname
, SAX1
org.xml.sax.Parser SAX2 org.xml.sax.XMLReader.
(
? ,
XML;
GEDCOM 10. ,
.)
,
, =, :
saxon source.xml style.xsl param1=value1 param2=value2
Saxon:
java com.icl.saxon.StyleSheet source.xml style.xsl param1=value1 param2=value2
Saxon
833
,
TrAX , ,
{namespaceuri}localname.
. ,
, param1="John Brown".
Saxon Java
Saxon Java
TrAX, F.
Templates,
(
)
.
.
Java, .
Saxon javax.xml.transform, dom, sax
stream, , .
SAXTransformerFactory,
SAX.
saxon.jar , , Saxon
XSLT TrAX TransformerFactory.
, , Saxon
TrAX, CLASSPATH,
TransformerFactory.newInstance()
TrAX Saxon.
, , Saxon, Xalan,
.
.
:
Saxon, Java,
javax.xml.transform.TransformerFactory
com.icl.saxon.
TransformerFactoryImpl.
D java, .
, :
java Djavax.xml.transform.TransformerFactory=
com.icl.saxon.TransformerFactoryImpl com.mycom.appl.Program
.
,
.
jaxp.properties $JAVA_HOME/lib (
$JAVA_HOME , Java)
=, javax.xml.
834
C. Saxon
.
, TrAX
, ,
.
Saxon
JAXP 1.1, javax.xml.parsers,
SAX DOM.
. SAX2
XMLReader SAX1 Parser,
(
), setAttribute()
TransformerFactory:
import com.icl.saxon.FeatureKeys;
TransformerFactory factory = TransformerFactory.newInstance();
factory.setAttribute(
FeatureKeys.SOURCE_PARSER_CLASS,
"org.apache.xerces.parsers.SAXParser");
factory.setAttribute(
FeatureKeys.STYLE_PARSER_CLASS,
" com.icl.saxon.aelfred.SAXDriver");
, Saxon
lfred.
, XML
SAX EntityResolver, .
, Java,
,
.
Saxon.
, :
import org.xml.sax.*;
import com.icl.saxon.aelfred.*;
public class CustomizedParser extends SAXDriver implements EntityResolver {
public CustomizedParser () {
setEntityResolver(this);
}
public InputSource resolveEntity(String publicId, String systemId)
throws org.xml.sax.SAXException, java.io.IOException {
if (systemId.equals("http://www.acme.com/standard.dtd")) {
835
Saxon
return new InputSource("file://e:/dtds/standard.dtd");
} else {
return null;
}
}
}
:
factory.setAttribute(
FeatureKeys.SOURCE_PARSER_CLASS,
"CustomizedParser");
, ,
DTD . (
resolveEntity() , ,
.)
Saxon,
setAttribute().
, com.icl.saxon.FeatureKeys,
, .
TIMING
. t
.
TREE_MODEL
, Builder.STANDARD_TREE, Buil
der.TINY_TREE.
. ( ,
TINY_TREE.)
TRACE_LISTENER
,
xon.trace.TraceListener.
LINE_NUMBERING
. l
.
RECOVERY_POLICY
.
: Controller.RECOVER_SILENTLY,
Controller.RECOVER_WITH_WARNINGS,
Controller.DO_NOT_RECOVER.
w0, w1 w2 .
com.icl.sa
MESSAGE_EMITTER_CLASS , ,
<xsl:message>.
com.icl.saxon.output.Emitter.
SOURCE_PARSER_CLASS
, ,
, ,
document().
SAX Parser, SAX2 XMLReader.
836
C. Saxon
STYLE_PARSER_CLASS
, ,
, ,
<xsl:include> <xsl:import>.
SAX Parser, SAX2 XMLReader.
TransformerFactory
setURIResolver() setErrorListener().
Saxon DOM
Saxon :
, Java.
DOM ,
W3C.
. , DOM,
.
,
;
.
XSLT XPath.
, ,
, , .
,
,
. ,
,
.
,
Saxon DOM .
DOM
TrAX DOMSource,
, Saxon
.
XML,
SAXSource. Saxon
MSXML3, DOM
.
DOM, ,
DOM,
Document. Saxon
Document,
DOM.
Saxon
837
Saxon Java,
DOM,
.
,
XPath, , CDATA
,
, . DOM
,
DOM Saxon.
XPath Saxon
Java API Saxon, XPath
,
.
XSLT, Java .
com.icl.saxon.expr.Expression.
make(),
XPath, .
, Expression,
.
evaluate(). , ,
, enumerate().
Expression.make() ;
XPath, , Sta
ticContext, ,
. ,
, .
, ,
, :
Expression exp = Expression.make("//item[@code='c']", new StandaloneContext());
StandaloneContext StaticContext,
.
; Context,
. ,
, . Saxon
Context org.w3.xsl.XSLTContext,
XSLT 1.1. Context
TrAX Transformer :
Context context = ((Controller)transformer).newContext();
, , ,
:
context.setContextNode(node);
838
C. Saxon
context.setPosition(1);
context.setLast(1);
, , :
Value val = exp.evaluate(context);
, Saxon
,
.
,
Saxon .
Saxon , .
Java
, XSLT 1.1,
8. ( 6.2) Saxon
, XSLT 1.1.
Saxon Java; JavaScript
. , ,
XSLT,
. 854 ( <saxon:function>).
Java <xsl:script>,
4. Saxon <xsl:script>,
language="java". ,
, java.util.Date, :
<xsl:script language="java" implementsprefix="Date" src="java:java.util.Date"/>
, :
<xsl:variable name="today" select="Date:new()"/>
.
Date URI java:
java.util.Date,
<xsl:script>. :
839
.
, Saxon 6.2, XSLT 1.1
.
, ,
,
, .
XSLT 1.1, Saxon
Java :
org.w3c.xsl.XSLTContext ,
, com.icl.saxon.Context. ,
, XPath, Saxon.
Context, Saxon
XPath,
. Context
,
.
TrAX Transformer ( Saxon com.icl.saxon.Controller),
,
, ,
.
Saxon XSLT.
.
, extensionelementprefixes
<xsl:stylesheet> xsl:extensionelementprefixes
.
.
, ,
. Saxon
,
.
.
, .
,
, com.icl.saxon.style.
ExtensionElementFactory.
840
C. Saxon
URI
: xmlns:xxx="http://icl.com/saxon/extensions/full.class.Name",
full.class.Name .
, ,
, com.icl.saxon.style.StyleElement.
ExtensionElementFactory .
getExtensionClass(),
.
StyleElement
, :
isInstruction()
.
mayContainTemplateBody()
,
. ,
,
<xsl:fallback>.
prepareAttributes()
,
,
.
validate()
.
,
;
,
, ,
/
.
process(Context c)
.
StyleElement,
Context.
,
.
Saxon SAX2. ,
SAX2 XMLReader. (
DOM, Saxon
SAX.)
.
841
Saxon SAX2.
,
Emitter, ContentHandlerProxy,
Emitter SAX2 ContentHandler.
.
ContentHandler Saxon
<xsl:output>, TrAX API.
:
,
XML , ,
.
TrAX XSLT ,
,
XSLT, Java.
F.
,
.
SAX Wrox
XML (Professional XML, ISBN 1861003110).
,
XML.
10,
GEDCOM, XML.
.
, XML,
XML
, .
,
SAX2;
, Apache FOP,
XSL (XSL Formatting Objects).
, ,
XML , .
Java Saxon
XSL. TrAX
saxon:nextinchain
<xsl:output>. , , ,
: <xsl:number>
, ,
, .
,
,
.
842
C. Saxon
Saxon ,
<xsl:sort>. lang
<xsl:sort>. , ,
,
: , ,
, , . . ,
, xmonths.
<xsl:number>. , ,
, , , . .
,
<xsl:number format="" lang="xmonths"/>.
Saxon
, Saxon
, .
Saxon (
, XSLT),
. ,
URI http://icl.com/saxon.
,
XPath.
, SQL
1 (firstclass functions) ,
. XSLT
XPath .
SQL ,
,
, , .
, XPath,
, ,
XPointer
. Saxon
1
, , ,
. . .
Saxon
843
: saxon:expression()
, saxon:eval()
,
, saxon:evaluate(),
.
, Saxon
.
URI .
xml:base URI,
,
systemid().
,
, , ,
ns1, ns2.
saxon:difference($a, $b)
XPath $a[count(.|$b) != count($b)].
distinct(ns1)
, ns1,
.
. :
<xsl:variable name="" select="saxon:distinct(//)"/>
,
<> .
<> ,
. ,
, , :
<xsl:foreach select="$">
<h2> : <xsl:valueof select="."/></h2>
<xsl:foreach select="//[.=current()]">
. . .
844
C. Saxon
( ) $a ,
saxon:distinct($a)
XPath $a[not(. = precedingsibling::*].
distinct(ns1,
expression)
, ns1,
,
. , ,
<>,
( ), :
<xsl:variable name="" select="saxon:distinct(//,
saxon:expression('substring(., 1, 1)'))"/>
,
.
:
<xsl:foreach select="$">
<xsl:variable name="" select="substring(., 1, 1)"/>
<h2><xsl:valueof select="$"/></h2>
<xsl:foreach select="//[substring(., 1, 1)=$]">
<p><xsl:valueof select="."/></p>
</xsl:foreach>
</xsl:foreach>
eval(expression) ,
.
saxon:expression(). (,
) ,
saxon:eval().
evaluate(string)
XPath .
, ,
,
.
, ,
<>, ,
:
<xsl:param name=""/>
<xsl:variable name="" select=
"saxon:evaluate(concat('//[', $, ']'))"/>
exists(ns1,
expression)
, ns1
, , ,
.
,
saxon:exists($a, expr) XPath bo
olean($a[expr]), .
expression
(string)
XPath, .
Saxon
845
saxon:eval() ,
, saxon:distinct()
saxon:sum().
XPath
,
, ,
. ,
.
forall(ns1,
expression)
,
ns1, ,
.
,
saxon:forall($a, expr) XPath
not($a[not(expr)]), .
getuserda
ta(string)
,
saxon:setuserdata().
.
,
, ,
.
.
TrAX Transformer,
.
hassamenodes
(ns1, ns2)
, ns1 ns2
. ,
=, ,
.
saxon:hassamenodes($a, $b)
XSLT:
count($a)=count($b) and count($a)=count($a|$b).
highest(ns1,
expression?)
ns1 ,
, (
).
,
, ,
. ,
<> @ * @,
:
<xsl:variable name=""
select="saxon:highest(//,
saxon:expression('@ * @'))"/>
if(condition,
v1, v2)
;
, v1, ,
846
C. Saxon
v2. .
, v1 v2 ,
, ,
.
intersection
(ns1,ns2)
,
;
, ns1, ns2.
,
,
, :
<xsl:foreach select="saxon:intersection(
key('', ''),
key('', ''))">
saxon:intersection($a, $b)
XPath $a[count(.|$b) = count($b)].
isnull(object) ,
null.
Java; ,
. ,
,
.
leading(ns1,
expression)
ns1
,
,
, .
, , <section>
:
<h1/><p/><p/><h1/><p/><p/><p/>
, <h1>,
<p> ( <h1>), :
<xsl:applytemplates
select="saxon:leading(
followingsibling::*,
saxon:expression('self::p'))"/>
saxon:before().
linenumber()
. .
,
. ,
l ,
.
Saxon
847
lowest(ns1,
expression?)
ns1 ,
, (
).
,
, ,
. ,
<> @ * @,
:
<xsl:variable name=""
select="saxon:lowest(//,
saxon:expression('@ * @'))"/>
max(ns1,
expression?)
ns1 . (
saxon:highest(), .)
,
,
, .
, @ * @
<>, :
<xsl:variable name=""
select="saxon:max(//,
saxon:expression('@ * @'))"/>
min(ns1,
expression?)
ns1 . (
saxon:lowest(), .)
,
,
, . ,
@ * @
<>, :
<xsl:variable name=""
select="saxon:min(//,
saxon:expression('@ * @'))"/>
XPath,
. (,
,
,
.)
848
C. Saxon
range(n1, n2)
,
n1 n2.
for. ,
1 5:
<xsl:foreach select="saxon:range(1,5)">
<td><xsl:valueof select="."/></td>
</xsl:foreach>
setuserda
ta(string,
value)
,
saxon:getuserdata().
.
,
, ,
.
.
TrAX Transformer,
. , sa
xon:setuserdata() ; ,
,
, .
systemid()
,
. .
.
tokenize(string, ,
delimiter?)
,
, .
,
<br/>
.
saxon:evaluate()
, ,
XPath ,
evaluate().
XSLT 1.0 ( 1.1) XPath,
. ,
SQL ASP JSP,
SQL .
Saxon
saxon:evaluate(). (
XSLT; .
.)
XPath
:
849
Saxon
: saxon:evaluate()
,
.
,
.
.xml:
<>
< ="20010115"
< ="20010116"
< ="20010118"
< ="20010118"
< ="20010124"
< ="20010125"
< ="20010127"
</>
="08.15"
="10.42"
="17.42"
="22.10"
="12:19"
="06.40"
="11.15"
="17"/>
="8"/>
="5"/>
="06"/>
="41"/>
="13"/>
="26"/>
. ,
, ;
.
.xml XPath.
,
:
<>
sum([@ >= 08.00 and @ < 18.00]/@) * 1.50 +
sum([@ < 08.00 or @ >= 18.00]/@) * 2.50
</>
850
C. Saxon
(.xsl)
.
, XPath
.xml ( saxon:evaluate())
.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
version="1.0">
<xsl:template match="/">
<html>
<head>
<title> ,
<xsl:valueof select="(//@)[last()]"/></title>
</head>
<body>
<h1> ,
<xsl:valueof select="(//@)[last()]"/></h1>
<xsl:applytemplates/>
</body>
</html>
</xsl:template>
<xsl:template match="">
<table>
<tr>
<th width="100"></th>
<th width="100"></th>
<th width="100"></th>
</tr>
<xsl:applytemplates/>
</table>
<xsl:variable name=""
select="saxon:evaluate(document('.xml'))"/>
<p> :
<xsl:valueof select="formatnumber($, '$###0.00')"/>
</p>
</xsl:template>
<xsl:template match="">
<tr>
<td><xsl:valueof select="@"/></td>
<td><xsl:valueof select="@"/></td>
<td><xsl:valueof select="@"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Saxon
851
. C.1. , saxon:evaluate()
Saxon
Saxon
, :
,
http://icl.com/saxon ( ).
extensionelement
prefixes <xsl:stylesheet>
xsl:extensionelementprefixes
.
saxon
: xsl,
, URI .
Saxon:
<saxon:assign>
,
<xsl:variable> ( <xsl:param>).
:
<saxon:assign name="n" select="$n+1"/>
852
C. Saxon
XSLT ,
. 9 .
,
.
saxon:assignable="yes", ,
.
, , .
, ,
, <saxon:assign>
.
<saxon:doctype>
XML
DOCTYPE,
DTD. <saxon:doctype>
DTD XML. :
<saxon:doctype xsl:extensionelementprefixes="saxon">
<dtd:doctype name=""
xmlns:dtd="http://icl.com/saxon/dtd"
xsl:excluderesultprefixes="dtd">
<dtd:element name="" content="()*"/>
<dtd:element name="" content="EMPTY"/>
<dtd:attlist element="">
<dtd:attribute name="isbn" type="ID" value="#REQUIRED"/>
<dtd:attribute name="" type="CDATA"
value="#IMPLIED"/>
</dtd:attlist>
<dtd:entity name="">'<i></i>
> 200 !'</dtd:entity>
<dtd:entity name="" system="cover.gif"
notation="GIF"/>
<dtd:notation name="GIF" system="http://gif.org/"/>
</dtd:doctype>
</saxon:doctype>
dtd
, ,
<saxon:doctype>.
<saxon:entityref> ,
, HTML. :
<saxon:entityref name="nbsp"/>
, :
<xsl:text disableoutputescaping="yes">&nbsp;
</xsl:text>
Saxon
853
( , ,
,
 , Saxon HTML
.)
<saxon:function>
<saxon:return>
<saxon:function>
,
, .
XSLT. , ,
Java JavaScript. <saxon:return>
<saxon:function>
.
<saxon:function>.
<saxon:group>
<saxon:item>
,
. <saxon:group>
<xsl:foreach>,
groupby, .
<saxon:group>
<saxon:item>. XSL <sa
xon:item>
. <saxon:item>
<saxon:group>.
, ,
, :
<saxon:group select="" groupby="">
<xsl:sort select=""/>
<xsl:valueof select=""/>:
<ul>
<saxon:item>
<li><xsl:valueof select=""/></li>
</saxon:item>
</ul>
</saxon:group>
<saxon:preview>
. , XSLT
,
.
. <saxon:preview>
;
,
.
<saxon:preview> : mode,
,
, elements,
854
C. Saxon
,
. , XML
<item>, elements="
item".
<saxon:while>
,
.
test.
, ,
, , <sa
xon:assign> , ,
. :
<xsl:variable name="n" select="10"/>
<saxon:while test="$n != 0">
<xsl:valueof select="$n"/>
<saxon:assign name="n" select="$n 1"/>
</saxon:while>
<saxon:function>
<saxon:function> XSLT ,
.
XSLT , .
, XPath
XSLT (, not() key()),
( ). XSLT 1.0
.
XSLT 1.1, 8,
Java JavaScript.
XPath Java
JavaScript. , XSLT
, ,
. saxon:function,
,
XSLT,
.
,
.
: saxon:function
.xml,
,
, . ,
855
Saxon
ISO:
<>
< ="27
< ="18
< ="18
< ="25
< ="15
< ="24
< ="16
</>
Jan
Jan
Feb
Jan
Mar
Jan
Jan
2001"
2001"
2001"
2001"
2001"
2001"
2001"
="11.15"
="17.42"
="22.10"
="06.40"
="08.15"
="12:19"
="10.42"
="26"/>
="5"/>
="06"/>
="13"/>
="17"/>
="41"/>
="8"/>
, .
( ,
.)
.xsl.
,
,
XSLT 1.1
.
, ,
. f:isodate(),
, .
<saxon:function>.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
xmlns:f="http://priceycallcentres.com/namespace"
extensionelementprefixes="saxon"
excluderesultprefixes="f" version="1.1">
<xsl:variable name="">
<xsl:foreach select="//">
<xsl:sort select="f:isodate(@)"/>
<xsl:sort select="@"/>
<xsl:copyof select="."/>
</xsl:foreach>
</xsl:variable>
<xsl:variable name=""
select="($//@)[last()]"/>
<xsl:template match="/">
<html>
856
C. Saxon
<head>
<title> ,
<xsl:valueof select="$"/></title>
</head>
<body>
<h1> ,
<xsl:valueof select="$"/></h1>
<table>
<tr>
<th width="100"></th>
<th width="100"></th>
<th width="100"></th>
</tr>
<xsl:applytemplates select="$/"/>
</table>
</body>
</html>
</xsl:template/>
<xsl:template match="">
<tr>
<td><xsl:valueof select="@"/></td>
<td><xsl:valueof select="@"/></td>
<td><xsl:valueof select="@"/></td>
</tr>
</xsl:template>
<saxon:function name="f:isodate">
<!
"21 Jan 1998" "19980121"
>
<xsl:param name=""/>
<xsl:variable name="" select="'JanFebMarAprMayJunJulAugSepOctNovDec'"/>
<xsl:variable name="" select="substring($, 1, 2)"/>
<xsl:variable name="" select="substring($, 4, 3)"/>
<xsl:variable name="" select="substring($, 8, 4)"/>
<xsl:variable name="" select="(stringlength(
substringbefore($, $)) div 3) +1"/>
<saxon:return select="concat($, formatnumber($, '00'), $)"/>
</saxon:function>
</xsl:stylesheet>
Saxon
857
:
. C.2. , saxon:function
, , <saxon:function>,
:
. ,
, , ,
. , <saxon:return> ,
Saxon
; , <saxon:return>
,
, ,
<saxon:function> .
Saxon
Saxon (xml, html
), <xsl:output> <xsl:document>,
XSLT 1.1.
<xsl:output>
<xsl:document>, setOutputProperties(),
TrAX API, F.
Saxon
.
Saxon (http://icl.com/saxon),
.
858
C. Saxon
:
method
:
saxon:fop
Apache FOP
XSL.
saxon:xhtml
XHTML, .
, <br/> <br /> ( ).
saxon:
Java,
SAX2 ContentHandler,
Saxon Emitter.
saxon:indentspaces
, ,
, indent="yes".
saxon:charactrrep ,
resentation
.
method="xml" ,
.
decimal,
(, &2345;), hex,
(, &x20a4;).
method="html"
, .
,
, ASCII,
, .
: native, entity, decimal hex.
decimal hex , XML
. , native ,
(
), entity
HTML,
Á, .
entity;decimal.
saxon:omitmetatag
yes no;
no. XSLT ,
HTML
<meta>. , ,
, XHTML,
. saxon:omitmetatag
.
859
saxon:nextinchain
URL XSLT.
,
. ,
(, , href
<xsl:document>),
.
Saxon ,
, : ascii, usascii, utf8, utf8, iso88591, iso88592, koi8r,
cp1250, windows1250, cp1251, windows1251.
, .
,
Java. ,
Saxon Java. Saxon ,
, Unicode ,
.
Java Unicode .
Saxon ,
Java. .
.
Saxon
,
.
Saxon
, Java:
XSLT 1.0
XSLT 1.1, JAXP 1.1.
(
).
Java
.
:
,
, ,
XSLT,
XML, DOM, XML,
XLink, XPointer .
D
Xalan
Xalan XSLT ,
Apache.
Xalan ,
, http://xml.apache.org/.
Xalan , LotusXSL,
(Scott
Boag) IBM, Lotus, Apache Software Foun
dation. LotusXSL, IBM
(http://www.alphaworks.ibm.com/),
Xalan. Apache
,
.
Apache, Xalan . ,
,
.
Xalan5Java 2
861
API TrAX,
F.
DOM2 SAX2. XalanJava 2 ,
. 1 ,
, ,
, ,
2.
Apache Software License,
,
, .
,
.
,
.
Xalan Apache XML Xerces; Java
Java Xerces Java, C++ C++
Xerces. XalanJava 2
, JAXP 1.1. Xalan
SAX2 ContentHandler DOM2,
: XML, HTML .
, Xalan
XSLT 1.0 XPath 1.0. XSLT
, ,
,
. Xalan ,
, , , .
XalanJava 2
http://xml.apache.org/,
Xalan.
zip ( Windows), .tar.gz,
Unix,
.
Java Virtual Machine.
Xalan Java IBM SUN 1.1.8, 1.2.2
1.3. Micro
soft JVM. , Xalan, , ,
, .
Xalan Xerces,
XML.
862
D. Xalan
XalanJava
XSLT Xalan
Java API. , ,
.
:
java org.apache.xalan.xslt.Process in a.xml xsl b.xsl out c.html
java Java.
, org.apache.xalan.xslt.Process , ,
xalan.jar .
org.apache.xerces.jaxp.SAXParserFactoryImpl,
, xerces.jar .
,
. ,
.
DIAG
EDUMP
HTML
HTML,
, <xsl:output>.
863
Xalan5Java 2
IN url
URL XML.
URL,
.
INDENT n
MEDIA
( :
.) media,
<?xmlstylesheet?> , .
media
<?xmlstylesheet?>.
OUT filename
,
. ,
System.out.
: .
QC
(
,
).
TEXT
, ,
<xsl:output>.
TG
,
.
TS
,
.
TT
, ,
.
864
D. Xalan
TTC
V
Xalan.
XML
XML,
, <xsl:output>.
XSL url
URL . URL,
. , Xalan
<?xmlstylesheet?>
.
,
, 10,
( ):
java org.apache.xalan.xslt.Process param start e5 in dummy.xml
xsl tour10.xsl out tour.html
, ,
tour10.xsl,
.
, dummy.xml
, XML. tour10.xsl
, XSLT 1.0
, 10,
XSLT 1.1.
tour10.xsl
, ,
.
:
java org.apache.xalan.xslt.Process param start e5 in tour10.xsl out tour.html
Xalan Java
Xalan Java API,
, .
XalanJava 2 TrAX API,
JAXP 1.1. TrAX API F.
API, XalanJava 1.
XalanJava 2 ,
XalanJava 1 API,
TrAX.
Xalan javax.xml.transform, dom, sax
stream , .
Xalan5Java 2
865
SAXTransformerFactory,
SAX.
xalan.jar java.xml.transform.
TransformerFactory , Xalan
XSLT, . ,
, Xalan TrAX,
CLASSPATH, TransformerFactory.newInstance()
Xalan TrAX.
TrAX, , Saxon Xalan, , .
. :
Xalan, Java,
javax.xml.transform.TransformerFactory org.apache.xalan.processor.
TransformerFactoryImpl. D java
. ,
:
java Djavax.xml.transform.TransformerFactory=
org.apache.xalan.processor.TransformerFactoryImpl
com.mycom.appl.Program
.
:
.
$JAVA_HOME/lib ( $JAVA_HOME
Java) jaxp.properties
=, javax.xml.transform.
TransformerFactory, Xalan org.apache.xalan.proces
sor.TransformerFactoryImpl.
System.setProperty ("javax.xml.transform.TransformerFac
tory", "org.apache.xalan.processor.TransformerFactoryImpl")
, .
,
TrAX , ,
.
Xalan SAX2 ,
JAXP 1.1, javax.xml.parsers.ParserFac
tory. JAXP 1.1 Crimson (org.apac
he.crimson.jaxp.SAXParserFactoryImpl), JavaXML
Apache, Sun Project X.
METAINF/services/javax.xml.parsers.SAXParserFactory,
xalan.jar, ,
org.apache.xerces.jaxp.SAXParserFactoryImpl.
866
D. Xalan
, Xerces
. xerces.jar Xalan.
, ,
javax.xml.parsers.SAXParserFactory.
ja
vax.xml.transform.sax.SAXSource,
;
, ,
, .
DOM Xalan
JAXP 1.1: javax.
xml.parsers.DocumentBuilderFactory. JAXP 1.1
crimson, META_INF xalan.jar
Xerces
DOM, org.apache.xerces.jaxp.DocumentBuiderFactoryImpl.
TrAX API :
Templates
.
, Templates ,
: ,
. Templates
,
. Xalan
: Templates , ,
. Xalan
Templates ( Java),
EJB (Enterprise JavaBeans).
XalanJava 1
XalanJava 2,
.
: , ,
.
Xalan DOM
Xalan
DOM2 DOM,
DOM2 .
DOM, Xalan
.
SAX XML, Xalan
, STree.
DTM, .
Xalan5Java 2
867
STree , DOM,
, ,
.
DOM2 . STree
DOM2,
,
.
STree ,
, ,
, .
,
, .
,
,
. Xalan,
,
,
; ,
Java , .
XML,
, , ,
.
,
<saxon:preview>, XSLT Saxon (. ),
.
XPath Xalan
Java API Xalan, XPath
.
XPath , DOM
:
Xalan (
Xalan).
: Java,
DOM,
XPath,
, XPointer, XPath.
XPath,
, org.apache.xpath.
XPathAPI.
.
868
D. Xalan
eval(Node contextNode,
String xPath)
XObject
eval(Node contextNode,
String xPath,
Node nsNode)
XObject
,
,
,
nsNode.
eval(Node contextNode,
String xPath,
PrefixResolver p)
XObject
, ,
,
PrefixResolver,
.
selectNodeIterator(
Node contextNode,
String xPath)
NodeIterator
XPath, .
, contextNode
.
DOM2 NodeIterator
( org.w3c.dom.traversal). ,
:
,
,
.
selectNodeIterator(
Node contextNode,
String xPath,
Node nsNode)
NodeIterator
,
,
,
nsNode.
selectNodeList(
Node contextNode,
String xPath)
NodeList
se
lectNodeIterator(), ,
DOM NodeList.
, .
selectNodeList(
Node contextNode,
String xPath,
Node nsNode)
NodeIterator
,
,
,
nsNode.
869
Xalan5Java 2
selectSingleNode(
Node contextNode,
String xPath)
Node
se
lectNodeIterator(), ,
DOM Node.
, ,
XPath , , (
, ).
selectSingleNode(
Node contextNode,
String xPath,
Node nsNode)
Node
,
,
,
nsNode.
XObject ,
XPath , , equals()
XPath, str()
.
Xalan ,
XPath .
XPath
XPath. :
java ApplyXPath XMLFile XPathExpression
. XPath .
XalanJava
Xalan org.apache.xalan.client.XSLTProcessorApplet,
,
, .
HTML, samples/AppletXMLtoHTML/appletXMLtoHTML.html,
,
. , ,
Java.
,
XML, HTML
.
870
D. Xalan
. D.1. XalanJava
HTML,
:
<applet
name="xslControl"
code="org.apache.xalan.client.XSLTProcessorApplet.class"
archive="../../bin/xalan.jar,../../bin/xerces.jar"
height="0"
width"0">
<param name="documentURL" value="default.xml"/>
<param name="styleURL" value="stylesheet.xsl"/>
</applet>
archive xalan.jar
xerces.jar HTML:
,
.
. , , ,
JavaScript:
document.xslControl.setDocumentURL(xmlFileName)
document.xslControl.setStyleURL(xslFileName)
:
<?xmlstylesheet?>,
.
Xalan5Java 2
871
:
document.xslControl.setStylesheetParam("startrecord", "1")
document.xslControl.setStylesheetParam("lastrecord", "5")
:
var outputHTML = document.xslControl.getHtmlText();
HTML
: <div id="resultArea">, :
resultArea.innerHTML = outputHTML;
Xalan
, ,
,
. Xalan
700 , Xerces 1450 .
,
Crimson, 185 .
,
, ,
, .
XalanJava
Xalan ,
. samples/servlet,
ApplyXSLT.java.
,
.
TrAX,
TrAX.
Xalan ,
, Xalan,
, .
, ,
, xalan.jar xerces.jar
, . ,
Xerces ,
SAX2.
,
samples/servlet , , bin/xalanservlet.jar.
,
, Java, .
,
, .
872
D. Xalan
. URL:
http://my.company.com/servlet/ApplyXSLT?URL=/source.xml&xslURL=/style.xsl
, XML source.xml
style.xsl .
.
URL, :
http://my.company.com/servlet/ApplyXSLT/source.xml?xslURL=/style.xsl
,
,
URL :
http://my.company.com/servlet/source.xml?xslURL=/style.xsl
<?xml
stylesheet?>, xslURL (
,
, ).
media.properties
,
HTTP,
.
ApplyXSLT ,
. ,
.
XSLT Java
Xalan Cocoon,
E. Cocoon
, ,
( ). Cocoon
,
,
. Cocoon
XalanJava, ,
, , TrAX API,
.
Xalan , .
Xalan
, ,
XSLT 1.1. .
Xalan5Java 2
873
Xalan
,
URI .
<xalan:component>.
<xalan:component>,
Java.
Java
, Java,
, URI
Xalan Java,
.
:
.
Java, :
<xsl:variable name="today" select="Date:new()" xmlns:Date="xalan://java.util.Date"/>
URI
. xalan://
, Xalan ,
/. ( , Saxon
xt , ,
.)
,
Java. ,
,
, , Java.
:
<xsl:variable name="today" select="java:java.util.Date.new()"
xmlns:java="http://xml.apache.org/xslt/java"/>
URI ,
. ,
Java
: ,
<xsl:stylesheet>, , .
,
, excluderesultprefixes.
Java
.
:
<xsl:variable name="today" select="util:Date.new()" xmlns:util="xalan://java.util"/>
,
Java. ,
.
874
D. Xalan
<xalan:component>
<xalan:component> ,
.
<xalan:component>
prefix
=
functions =
elements = >
<xalan:script>...</xalan:script>
</xalan:component>
<xalan:component> ,
<xsl:stylesheet>
<xsl:transform>.
<xalan:component>,
.
, ,
, <xalan:component>
, ,
extensionelementprefixes
<xsl:stylesheet>. , .
prefix
,
,
,
functions
(
)
elements
(
)
<xalan:component> <xalan:script>
.
875
Xalan5Java 2
:
,
, .
, , <xalan:component>
<xalan:script>, , , ,
.
<xalan:script>
<xalan:script>
.
<xalan:script
lang = "javaclass" | "javascript" |
src = .
</xalan:script>
<xalan:script>
<xalan:component>.
lang
src
lang="javaclass".
,
,
Java
:
xalan://java.util.Date
http://xml.apache.org/xslt/java
,
xalan://java.util
Java
a
876
D. Xalan
Java <xalan:script> ,
JavaScript
. CDATA,
.
: Java
Java lang java
class. src
.
Java,
.
src (
xalan://java.util.Date), : prefix:function(args).
:
new
,
,
, ,
src http://xml.apache.org/xslt/java,
, full.class.Name
Java, :
full.class.Name.new
full.class.Name.method, method
full.class.Name.method, method ,
.
, src xalan://package.name,
, Class
:
Class.new
Class.method, method
Class.method, method ,
Java .
Xalan
XPath, , Java,
.
, ,
XSLT 1.1, .
877
Xalan5Java 2
XPath, ,
Java ,
. (,
, ).
XPath
Java
org.w3c.dom.traversal.NodeIterator, org.w3c.dom.NodeList,
org.w3c.dom.Node java.lang.String, ja
va.lang.Object, char, [double, float, long, int, short, byte], boolean
org.w3c.dom.traversal.NodeIterator, org.w3c.dom.DocumentFragment,
org.w3c.dom.Node java.lang.String, ja
va.lang.Object, char, [double, float, long, int, short, byte], boolean
, Xalan
, .
, .
Java
org.apache.xalan.extensions.ExpressionContext.
w3c.org.xsl.XSLTContext,
XSLT 1.1, . ExpressionContext
XPath.
: JavaScript
Xalan Java Ja
vaScript, , Bean Scrip
ting Framework, Perl Python.
, JavaScript, ,
.
JavaScript ,
<xalan:script>, <xalan:component>.
user:datePlus()
<user:trace>.
878
D. Xalan
: JavaScript
Xalan
.
xalanscript.xsl.
Xalan,
URI user.
<user:trace>
user:datePlus().
,
.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
xmlns:user="http://any.user.com/xslt/extension1"
extensionelementprefixes="user">
<xalan:component prefix="user" elements="trace" functions="datePlus">
<xalan:script lang="javascript">
function trace (xslProcessorContext, extensionElement) {
return " trace, =" +
extensionElement.getAttribute("message");
}
function datePlus (days) {
var d = new Date();
d.setDate(d.getDate() + parseInt(days));
return d.toLocaleString();
}
</xalan:script>
</xalan:component>
<xsl:template match="/">
<html><body>
<p><user:trace message=""/></p>
<p> 5 <xsl:valueof
select="user:datePlus(5)"/></p>
<p><user:trace message=""/></p>
</body></html>
</xsl:template>
</xsl:stylesheet>
<html>
<body>
<p> trace,=</p>
<p> 5 February 25, 2001 11:36:25 AM GMT +00:00</p>
<p> trace, =</p>
Xalan5Java 2
879
</body>
</html>
,
.
:
Java
XML Xerces
XSLT Xalan
Bean Scripting Framework
Rhino JavaScript
, Xalan http://xml.
apache.org; Xerces. Bean Scripting Frame
work Xalan. Rhino Javascript
http://www.mozilla.org/rhino/. XalanJava 2
Rhino 1.5.
:
java cp XXX org.apache.xalan.xslt.Process in dummy.xml xsl xalanscript.xsl
XXX Java. .
, , ,
.
D:\JavaLib\xerces\xercesj_1_2_3\xerces.jar;
D:\JavaLib\xalan\xalanj_2_0_0\xalan.jar;
D:\JavaLib\rhino\js.jar;
D:\JavaLib\xalan\xalanj_2_0_0\bsf.jar
:
. , :
Java,
.
Java
:
org.apache.xalan.extensions.
XSLProcessorContext.
, , ,
.
org.apache.xalan.templates.ElemExtensionCall.
,
. ,
,
.
880
D. Xalan
( XalanJava 2. XalanJava 1
.)
Xalan DOM,
DOM.
, .
Xalan ,
.
xalan:xxx,
:
xmlns:xalan="http://xml.apache.org/xalan"
:
difference
(ns1, ns2)
,
; , ns1
ns2.
distinct(ns1) ns1,
.
<xsl:variable name="" select="xalan:distinct(//)"/>
,
<> , .
<> ,
,
, , ,
:
<xsl:foreach select="$">
<h2> : <xsl:valueof select="."/></h2>
<xsl:foreach select="//[.=current()]">
. . .
evaluate
(string)
XPath
. ,
,
,
. , ,
<>, ,
:
<xsl:param name=""/>
<xsl:variable name="" select=
"xalan:evaluate(concat('//[', $, ']'))"/>
881
Xalan5Java 2
hasSameNodes , ,
(ns1, ns2)
, ns1 ns2 .
, =,
, .
XSLT :
<xsl:if test="count(ns1)=count(ns2) and count(ns1)=count(ns1|ns2)">
intersection ,
(ns1,ns2)
;
, ns1, ns2.
,
, ,
:
<xsl:foreach select="xalan:intersection(
key('', ''),
key('', ''))">
nodeset(tree)
.
XSLT 1.0 ( XSLT 1.1)
, .
tokenize
(string,
delimiter?)
,
,
, .
,
<br/> ,
.
SQL
Xalan
JDBC, .
.
: xmlns:sql="org.apache.xalan.lib.sql.XConnection".
sql:new() .
.
JDBC; URL,
,
.
sql:query(connection, selectStatement) .
, sql:new(),
SELECT SQL .
,
, Xalan. , ,
, :
<xsl:copyof select="sql:query($connection, 'SELECT * FROM EMP')"/>
882
D. Xalan
sql:close(connection) .
, ,
, .
JDBC, (
JDBC:ODBC). ,
, Wrox
, !
, Xalan,
, <xa
lan:redirect>. , <xsl:do
cument>, XSLT 1.1,
4, .
XSLT
.
( xmlns:redirect="org.apache.xalan.xslt.
extensions.Redirect") (extensionelement
prefixes="redirect").
<xalan:write>,
: ,
, ;
<xalan:open> <xalan:close>:
,
. .
file / select .
select, ,
. ,
file. mkdirs,
, ,
, .
.
:
, ,
.
, .
.xml.
:
<>
<> </>
Xalan5Java 2
883
<>1912</>
<>Song</>
<>
<>And suddenly the wind comes soft,</>
<>And Spring is here again;</>
<>And the hawthorn quickens with buds of green</>
<>And my heart with buds of pain.</>
</>
<>
<>My heart all Winter lay so numb,</>
<>The earth so dead and frore,</>
. . .
xalansplit.xsl.
, xalan ,
<xalan:write> .
, ,
, .
<xsl:variable>,
, ,
.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="org.apache.xalan.xslt.extensions.Redirect"
extensionelementprefixes="xalan" version="1.0">
<xsl:template match="poem">
<>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:copyof select=""/>
<xsl:applytemplates select=""/>
</>
</xsl:template>
<xsl:template match="">
<xsl:variable name="" select="concat('', position(), '.xml')"/>
< ="{position()}" href="{$}"/>
<xalan:write select="$">
<xsl:copyof select="."/>
</xalan:write>
</xsl:template>
</xsl:stylesheet>
(
):
<?xml version="1.0" encoding="utf8" ?>
<>
884
D. Xalan
<>Song</>
<> </>
<>1912</>
< ="1" href="1.xml"/>
< ="2" href="2.xml"/>
< ="3" href="3.xml"/>
</>
Xalan
Xalan ,
XSLT,
,
, ,
DOM. Xalan
SAX2 ContentHandler.
Xalan (xml, html text),
<xsl:output> XSLT 1.0.
,
, , indent="yes", ,
. , Xalan
, .
xalan:indentamount ,
, .
<xsl:output>,
setOutputProperties() TrAX API,
F.
Xalan
.
Xalan (http://xml.apache.org/xslt),
.
, :
<xsl:output method="xml" indent="yes" xalan:indentamount="5"
xmlns:xalan="http://xml.apache.org/xslt"/>
885
Xalan
,
src/org/apache/xalan/templates
xalan.jar . ,
,
output_xxx.properties, xxx html, text xml.
Xalan :
xalan:indentamount
XML, HTML
.
0, .
xalan:contenthandler
xalan:entities
XML, HTML
,
HTML,
é.
HTMLEntities.res.
xalan:useurlescaping
HTML
,
URL, HTML
%HH.
yes;
no,
.
xalan:entities
. ,
:
<xsl:output xalan:entities="myEntities.txt"/>
myEntities.txt :
quot 34
amp 38
lt 60
gt 62
nbsp 160
, <,
( Unicode #160 #xA0)
(,
, ).
Xalan
, Java.
, ISO 8859/1, Xalan
ISO (iso88591), XML,
886
D. Xalan
Java (ISO8859_1).
Unicode,
, ࠈ.
: , USASCII 127;
ISO 8859 255; EBCDIC 255; ,
, utf8 utf16, 65 535.
XalanC++
,
Java Xalan, C++,
,
.
, , Ja
va, , ,
: ,
. , ,
( 1.1)
.
XalanC++ http://xml.apache.org,
, ,
. Windows,
DLL ,
. ,
PATH,
autoexec.bat.
TestXSLT
, XalanJava.
:
TestXSLT IN source.xml XSL style.xsl OUT output.html
.
.
DOM
DOM,
. ,
XML.
EER
,
.
887
Xalan5C++
ESCAPE
, (
<>&"'\r\n).
ESCAPECDATA
CDATA
.
HTML
HTML.
IN
URL .
INDENT n
,
( ).
NH
XML.
OUT
,
.
QC
.
STRIPCDATA
CDATA,
.
TEXT
TEXT.
TG
,
.
TS
,
.
TT
TTC
V
VALIDATE
,
XML.
XML
XML.
XSL
URL .
888
D. Xalan
Unicode
Java, C++ Unicode.
XalanC++
Unicode (International Components for Unicode, ICU),
IBM IBM's DeveloperWorks.
; ,
formatnumber() <xsl:sort>, Unicode.
Unicode
XercesC++ Xerces
.
XalanC++ C C++.
.
Function. , , execu
te(), , clone(),
Xalan .
XalanC++
, Java.
,
,
. , XSLTProcessorEnvSup
portDefault installExternalFunctionGlobal()
installExtensionFunctionLocal().
URI ,
, Function.
Xalan ,
, Apache. ,
,
, , ,
, ,
.
, :
, , .
Java, ++,
Java.
, .
XSLT (MSXML3, Saxon, Oracle Xalan). ,
, , 90% XSLT
. ,
,
,
.
,
XSLT,
XSLT.
.
,
XML,
XSLT, ,
,
. ,
, , ,
, ,
.
XSLT, XML,
http://www.xmlsoftware.com/.
,
:
890
E.
4XSLT
XSLT ,
Python. FourThought ,
(Boulder, Colorado),
(Uche Ogbuji). http://
www.fourthought.com/,
http://4suite.org/index.epy.
4XSLT
XML, ,
. XSLT
XML SAX DOM, XLink
XPointer, RDF, .
,
Python.
4XSLT ( )
XSLT 1.0 XPath 1.0. XPath
, DOM.
XSLT
Python. ,
Python.
.
:
ft:applytemplates
xsl:applytemplates,
ft:writefile
( XSLT 1.1
<xsl:document>)
ft:messageoutput
<xsl:message>
4XSLT
891
4XSLT ,
,
:
ft:nodeset()
ft:match()
,
ft:escapeurl()
, URL
ft:isotime()
ISO 8601
ft:evaluate()
XPath,
ft:distinct()
ft:split()
,
ft:range()
,
ft:if()
ft:find()
,
(Jeni Tennison); .
http://www.jenitennison.com/xslt/exslt/common/.
,
,
,
, ,
. ,
4XSLT ,
.
4XSLT; ,
, Python
, . Python
,
, .
. http://www.python.org.
892
E.
Cocoon
Cocoon XSLT,
. , XML,
XSLT . Cocoon
XML,
Apache, http://
xml.apache.org/.
Xalan XSLT, D, , , Xalan
Cocoon.
Cocoon ,
. XSLT ,
, Cocoon
.
, ( XML),
.
Cocoon
, XSLT
,
. ,
. Cocoon SQL
LDAP.1
Cocoon XSP.
(eXtensible Server Pages, XSP)
XML,
. ,
ASP JSP ( ),
. ,
, Java ,
Enterprise Java Beans.
Cocoon; ,
. ,
XSLT Co
coon, , , Xalan, .
EZ/X
http://www.activated.com/products/
products.html.
Java, XML XSLT
.
1
iXSLT
893
, , , ,
. ,
XSLT 1999 ,
XSLT 1.0.
,
.
,
.
iXSLT
iXSLT Infoteria (http://
www.infoteria.com).
XSLT Windows.
,
Windows:
.
,
CDROM
. 2.0c, 2000 .
iXSLT DLL Windows,
COM C++.
, Windows .
.
,
.
, , ,
, , .
PDF. , ,
, ,
. ,
XSLT 1.0, .
, , ,
.
readme
.
,
894
E.
,
XPath, .
. E.1. iXSLT
jd:xslt
Java XSLT,
5 2001 (Johannes Dbler) ,
, . ,
, .
,
,
,
, , ,
. , ,
XSLT 1.1,
, .
,
, , 1.0
.
, ,
.
,
.
895
Sablotron
, ,
.
http://www.aztecrider.com/xslt/jd.zip.
Mozilla Public License.
jd:xslt XML Crimson Apache.
,
DOM.
Java API, TrAX API, F.
( XSLT 1.1
).
Java JavaScript.
XSLT ,
Java. , ,
, ; ,
, , , , jd:xslt
.
jd:xslt
37K
19K
Saxon
63K
31K
Xalan
118K
46K
xt
15K
13K
Sablotron
Sablotron XSLT,
Ginger Alliance1,
XML. http://
www.gingerall.com/.
Ginger Alliance Charlie
(middleware),
XML. Sablotron, C++
, :
, ,
XSLT Charlie,
. Sablotron
,
, . .
.
1
Ginger Alliance , . . .
896
E.
Stylus Studio
Excelon, ( ,
), Ob
jectStore, XML,
. XML
Stylus Studio.
http://www.exceloncorp.com/products/excelon_stylus.html.
,
XSLT
. ,
(Stylus 3.0) .
XSLT MSXML3 Microsoft, XSLT
Excelon. XSLT 1.0
; , Excelon
, XSLT.
Stylus Studio .
,
.
Stylus 3.0, ,
,
. ,
Windows 2000 NT
(,
).
, ,
( ), 40
.
Stylus Studio
, XML ,
.
XSLT.
XSLT,
.
Stylus Studio
897
XSLT, ,
. ,
.
Stylus ,
XML. , ,
.
, ,
, ,
, .
Templates. XML Stylus
DTD XML.
,
. , Stylus
,
.
HTML,
. Stylus
HTML ,
,
,
HTML .
XPath, Stylus
XPath, XPath
; ,
.
Mapper,
.
, ,
.
, .
, ,
, ,
. , ,
,
;
<xsl:foreach> .
,
. , <F5>,
, XML, ,
HTML. ,
, ,
, .
898
E.
. E.2. Mapper
Stylus Studio
,
, .
,
. ,
,
Java.
Stylus Studio XSLT.
XSLT 1.0, , :
. ,
(, 250 )
.
: Stylus Studio
, XSLT
.
TransforMiix
TransforMiix XSLT,
Mozilla.
Mozilla, MSXML3 Inter
net Explorer. http://www.mozilla.org/
projects/xslt/. (Keith Vis
co) (Peter van der Becken).
Unicorn
899
TransforMiix ,
. ! ,
, ,
. ,
Windows Linux, ,
, ,
, , ,
Mozilla.
Netscape/Mozilla
, TransforMiix
. XSLT,
,
TransforMiix. , Linux
Mozilla , .
Unicorn
Unicorn XML Toolkit XSLT
, C++.
Microsoft Windows. Unicorn Enterpri
ses, (Schwyz), .
.
http://www.unicornenterprises.com/.
, ,
, ,
XSLT, .
,
. .zip ,
c:\unicorn, :
uxt demo\demo.xml demo\demo.xsl c:\output.html
,
:
XSLT,
.
,
, .
,
.
,
Microsoft ActiveX.
900
E.
XML,
, ++ SAX2, DOM1,
XPath , , XSLT 1.0.
ECMAScript .
, XSL.
XSLT 1.0
XPath 1.0. (
),
.
,
++ ECMAScript ( JavaScript ).
ECMAScript,
COM.
Unicorn
,
, , ODBC. ,
.
. .
<xsl:template match='/'>
<root>
<sql:connect
source="{$source}"
user="{$user}"
authentication="{$authentication}"
type="odbc"
connectionid="dbc1"/>
<sql:prepare
connectionid="dbc1"
sql="INSERT INTO PRODUCT (CODE, CATEGORY, NAME)
VALUES (?, ?, ?)"
statementid="stmt1">
<sql:param type="CHAR" precision="64"/>
<sql:param type="CHAR" precision="64"/>
<sql:param type="CHAR" precision="64"/>
</sql:prepare>
<xsl:applytemplates/>
</root>
</xsl:template>
<xsl:template match="product">
<sql:execute statementid="stmt1">
<sql:withparam value="{code}"/>
<sql:withparam value="{category}"/>
Unicorn
901
<sql:withparam value="{name}"/>
</sql:execute>
</xsl:template>
.
PRODUCT,
( ),
XML .
.
<xsl:param name="category" select="'Desktop'"/>
<xsl:template match='/'>
<root>
<sql:connect
source="{$source}"
user="{$user}"
authentication="{$authentication}"
type="odbc"
connectionid="dbc1"/>
<sql:prepare
connectionid="dbc1"
sql="SELECT CODE, CATEGORY, NAME FROM PRODUCT
WHERE CATEGORY=? ORDER BY CODE"
statementid="stmt1">
<sql:param type="CHAR" precision="50"/>
</sql:prepare>
<sql:foreach statementid="stmt1">
<sql:withparam value="{$category}"/>
<product>
<code><xsl:valueof select="sql:fetch('CODE')"/></code>
<category><xsl:valueof select="sql:fetch('CATEGORY')"/></category>
<name><xsl:valueof select="sql:fetch('NAME')"/></name>
</product>
</sql:foreach>
</root>
</xsl:template>
Unicorn XSLT,
, , , :
.
, ,
<rpt:
counter>. Saxon <saxon:assign>,
XSLT
.
902
E.
<rpt:group>.
<rpt:group> ,
,
. <rpt:group>
. :
<rpt:group select="" key="@">
< ="{@}">
<rpt:group>
<xsl:copyof select=""/>
</rpt:group>
</>
</rpt:group>
<rpt:sort>,
<xsl:sort>.
Unicorn ,
,
, ,
, .
<txt:format>, <txt:field>,
.
:
<txt:format name="TEXT01">
<txt:field name="" width="10"/>
<txt:field name="" width="15"/>
<txt:field name="" width="50"/>
</txt:format>
:
<txt:format name="TEXT02" separator=",">
<txt:field name=""/>
<txt:field name=""/>
<txt:field name=""/>
</txt:format>
<txt:read>;
txt:fieldvalue():
<txt:read href="text02.txt" format="TEXT02">
<>
<><xsl:valueof select="txt:fieldvalue('')"/></>
<><xsl:valueof select="txt:fieldvalue('')"/></>
<><xsl:valueof select="txt:fieldvalue('')"/></>
</>
</txt:read>
XESALT
903
XESALT
XESALT XSLT
Inlogix, , .
.
http://www.inlogix.de/xesalt.html.
:
, , . ,
, , .
, ,
, ( 2001 ), ,
2000 ; ,
.
, ,
, .
XML Spy
XML Spy Altova GmbH , .
1992 ,
Icon Information Systems. , ,
: ,
XML Spy, http://www.xmlspy.com/.
200
. 30
.
XML Spy XSLT , ,
XML . ,
,
.
XML Spy
, .
.
,
,
: (Insert), (Append)
(Add Child) ,
.
904
E.
, ,
, DTD
, .
, ,
XML :
. E.3. XML
XML Spy
, ,
:
XML Spy
905
XML Spy
XML, .
.
XML HTML .
,
.
XSLT,
, .
,
<?xmlstylesheet?>
, .
XSLT:
MSXML3, Saxon Infoteria iXSLT, ,
, ,
. ,
, XSLT,
, XML Spy ,
.
, XML Spy
DTD XML (
, ).
DTD
,
.
.
906
E.
XSL Composer
, Whitehill
Technologies http://www.whitehill.com/. XSLT
,
XSLT.
XML HTML
, XSLT .
HTML,
XSLT. XSLT, , ,
,
, .
modus operandi1
XML ,
HTML. :
.
:
,
, , ,
.
. XML
,
,
. , ,
HTML
. , ,
, .
,
XML, DTD.
, <>
<>
, .
XPath Builder,
, XPath.
, ,
XSLT, .
, XSLT .
, ,
. ,
.
, (.). . .
XSLTC
907
XSLTC
,
, http://www.sun.com/xml/developers/xsltc/.
XSLTC Sun XSLT,
, , , ,
, .
, Java. ,
Java; .class,
Java. .class,
XSLTC, ( ,
) (translet),
Java , Java.
, ,
, .
:
, 750 (,
XML, 10),
,
30 . .jar,
13 ,
. , ,
, : xml.jar ( XML)
127 xsltrc.jar (
XSLT) 109 .
, Saxon (555 ) Xalan (687 ),
, xt (345 ).
, , , ,
, xt
Saxon. , ,
, ,
.
,
,
, ,
.
, .
, Sun
, Java
, ,
, (justintime) (, HotSpot),
, , ,
. , Sun
, .
908
E.
. ,
, ,
XSLT. ,
; , Saxon,
,
. , Xalan,
,
.
.
XSLTC
XSLT 1.0, .
, (
, Windows
). ,
, .
xt
xt XSLT ,
.
,
XSLT 1.0 . ,
(
). , 19991105,
.
Saxon, xt ,
. , ,
, ,
. . Java
.
xt http://www.jclark.com/xml/xt.html.
XSLT 1.0 XPath 1.0:
( extensionelementprefixes
xsl:extensionelementprefixes, <xsl:fallback> element
available())
( <xsl:key> key())
<xsl:decimalformat>
formatnumber(), <xsl:decimalformat>
namespace
909
xt
xsl:excluderesultprefixes
( excluderesultprefixes <xsl:stylesheet> )
,
, ,
xt, XSLT
. , xt
,
.
xt
xt , Java API
.
:
java com.jclark.xsl.sax.Driver source.xml style.xsl out.html param1=value1...
Windows,
:
xt source.xml style.xsl out.html param1=value1...
Windows
.
Java, xt
SAX, SAX XML,
SAX
SAX.
xt SAX1 XML,
.
xp,
SAX1, ,
.
param1=value1
; .
xt Java API,
. ,
. ,
Java API,
. , ,
( xt.jar, WinZip
ZIP), ,
SAX DOM, xt,
.
910
E.
xt
Java.
Java URI ,
. :
<xsl:variable name="" select="Date:new()"
xmlns:Date="http://www.jclark.com/xt/java.util.Date"/>
. URI
, http://www.jclark.com/xt/.
xt ,
.
: Java,
.
XPath Java
, .
xt ,
, .
xt ,
, XML, ,
.
.
xt <xt:document>,
.
xt ( )
URI : http://www.jclark.com/xt.
<xt:document> <xsl:document>,
XSLT 1.1, 4.
<xt:document> href,
URI. href
. <xt:document>
, ,
href. URL URL
URL : URL
, URL ,
<xt:document>. , URL,
href,
, <xt:document>.
911
xt
<xt:document> ,
<xsl:output>. ,
<xsl:output> ,
. <xt:document> ,
<xsl:output> .
, XML
XSLT
<xsl:output method="text">; . ,
, XML.
xt
xt:nxml, xt URI
http://www.jclark.com/xt. XML,
:
<char> ,
XML,
#x20.
<data> . <data>
.
<escape> ,
.
<control> ,
, .
: xt
.
xttext.xsl.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xt:nxml" xmlns:xt="http://www.jclark.com/xt"/>
<xsl:template match="/">
<nxml>
<escape char="\">\\</escape>
<data>&<>\</data>
<control>&<>\</control>
</nxml>
</xsl:template>
</xsl:stylesheet>
&<>\\&<>\
912
E.
method <xsl:output> <xt:document>
java:package.name.class, java URI
http://www.jclark.com/xt/java, package.name.class Java
, com.jclark.xsl.sax.OutputDocumentHandler (
SAX1 org.xml.sax.DocumentHandler).
.
xt .
URI : http://www.jclark.com/xt.
xt:nodeset (frag)
.
.
.
(
, ).
,
XSLT.
, ; ,
;
, , , .
, .
, , .
,
,
. , 2001
,
. ,
.
,
.
F
TrAX: API XML
914
TrAX
Saxon Xalan. ,
.
, . [SAXE, IOE]
, :
FCE
javax.xml.parsers.FactoryConfigurationError
IAE
java.lang.IllegalArgumentException
IOE
java.io.IOException
PCE
javax.xml.parsers.ParserConfigurationException
SAXE
org.xml.sax.SAXException
SAXNRE
org.xml.sax.SAXNotRecognizedException
SAXNSE
org.xml.sax.SAXNotSupportedException
TCE
javax.xml.transform.TransformerConfigurationException
TE
javax.xml.transform.TransformerException
TFCE
javax.xml.transform.TransformerFactoryConfigurationError
SAX JAXP
JAXP 1.0 SAX1; JAXP 1.1 SAX2,
JAXP 1.0. ,
SAX1, .
915
javax.xml.parsers.SAXParserFactory
,
SAXParserFactory, SAXPar
serFactory.newInstance(). SAX
SAXParserFactory,
,
. ,
:
javax.xml.parsers.SAXParserFactory,
. ,
D java
System.setProperty() .
$JAVA_HOME/lib/jaxp.properties,
javax.xml.parsers.
SAXParserFactory.
API, JAR.
, ,
.jar,
. ,
,
CLASSPATH.
SAXParserFactory,
. , , newSAXPar
ser() SAXParser.
.
, .
boolean getFeature(String)
[SAXNRE, SAXNSE, PCE]
,
.
SAX2 XMLReader.
boolean isNamespaceAware()
, ,
, .
boolean isValidating()
, ,
, XML .
916
SAXParser newSAXParser()
[PCE]
SAXParser,
.
SAX2 XMLReader.
,
SAX2 XMLReader.
void setNamespaceAware(boolean)
, ,
,
.
void setValidating(boolean)
, ,
,
XML .
javax.xml.parsers.SAXParser
SAXParser newSAXParser()
SAXParserFactory. SAXParser SAX2 XMLReader.
XMLReader SAX1 Parser.
XMLReader getXMLReader(),
,
,
, SAXParser.
, SAX2:
Object getProperty(String)
[SAXNRE, SAXNSE]
SAX2 XMLReader.
XMLReader getXMLReader()
[SAXE]
SAX2 XMLReader.
boolean isNamespaceAware()
, SAX2 XMLReader
.
boolean isValidating()
, SAX2
XMLReader XML.
void parse(File,
DefaultHandler)
[IOE, IAE, SAXE]
File, ,
. ,
, DefaultHandler, SAX2,
DefaultHandler,
.
void parse(InputSource,
DefaultHandler)
[IOE, IAE, SAXE]
SAX InputSource,
,
, .
917
void parse(InputStream,
DefaultHandler)
[IOE, IAE, SAXE]
InputStream,
, ,
. ,
,
URI URI,
XML.
void parse(InputStream,
DefaultHandler, String)
[IOE, IAE, SAXE]
InputStream,
, ,
.
,
URI.
void parse(String,
DefaultHandler)
[IOE, IAE, SAXE]
XML,
URI ,
, ,
.
void setProperty(String,
Object)
[SAXNSE, SAXNRE]
SAX2
XMLReader.
DOM JAXP
JAXP 1.0 DOM
, JAXP 1.1 DOM . DOM
,
, ( )
XML.
DOM
, ,
DOM
XML. JAXP 1.1
.
DOM SAX :
DocumentBuilderFactory.newInstance()
DocumentBuilderFactory,
DOM.
newDocumentBuilder() ,
DocumentBuilder.
, parse()
DocumentBuilder DOM Document.
918
javax.xml.parsers.DocumentBuilderFactory
,
DocumentBuilderFactory,
DocumentBuilderFactory.newInstance(). DOM
SAXParserFactory,
,
. ,
:
javax.xml.parsers.
DocumentBuilderFactory, . ,
D java
System.setProperty() .
$JAVA_HOME/lib/jaxp.properties
javax.xml.parsers.
DocumentBuilderFactory.
API, JAR.
, DOM ,
.jar,
.
,
CLASSPATH.
DocumentBuilderFactory,
newDocumentBuilder()
DocumentBuilder.
:
Object getAttribute(String)
[IAE]
.
boolean isCoalescing()
, DocumentBuilder
CDATA
.
boolean isExpandEntityReferences()
, DocumentBuilder
.
boolean isIgnoringComments()
, DocumentBuilder
XML
.
boolean isIgnoringElementContent
Whitespace()
, DocumentBuilder
.
919
boolean isNamespaceAware()
, DocumentBuilder
.
boolean isValidating()
, DocumentBuilder
XML
.
DocumentBuilderFactory
,
.
setAttribute(String, Object)
[IAE]
.
void setCoalescing(boolean)
, DocumentBuilder
CDATA
.
void setExpandEntityReferences
(boolean)
, DocumentBuilder
.
void setIgnoringComments(boolean)
, DocumentBuilder
XML
.
void setIgnoringElementContent
Whitespace(boolean)
, DocumentBuilder
.
void setNamespaceAware(boolean)
, DocumentBuilder
.
void setValidating(boolean)
, DocumentBuilder
XML
.
javax.xml.parsers.DocumentBuilder
DocumentBuilder newDo
cumentBuilder() DocumentBuilderFactory.
DocumentBuilder
XML org.w3.dom.Document,
.
, SAX
. , DocumentBuilder SAX
920
:
, . ,
SAX DOM.
, , DOM Microsoft Document
load(), XML
Document. Microsoft
W3C DOM. DocumentBuilder .
boolean isNamespaceAware()
,
XML.
boolean isValidating()
,
XML
.
Document newDocument()
Document
.
DOM,
createElement().
Document parse(File)
[IOE, SAXE, IAE]
XML
Document.
Document parse(InputSource)
[IOE, SAXE, IAE]
XML
SAX InputSource
Document.
Document parse(InputStream)
[IOE, SAXE, IAE]
XML
InputStream
Document. ,
,
URI
URI, .
XML In
putStream
Document.
,
URI.
Document parse(String)
[IOE, SAXE, IAE]
XML,
URI,
Document.
void setEntityResolver(EntityResolver)
SAX EntityResolver.
void setErrorHandler(ErrorHandler)
SAX ErrorHandler.
921
922
Transformer
Factory
.
Templates
.
Transformer
.
SAXTrans
formerFactory
SAX
XMLFilter.
Source
.
Result
SAXSource
SAX.
DOMSource
DOM Do
cument.
StreamSource
XML.
SAXResult
SAX.
DOMResult
DOM Document.
StreamResult
XML ( HTML,
).
URIResolver
,
URI,
(, docu
ment()),
Source.
ErrorListener
,
. ErrorListener
,
.
SourceLocator
, .
DOMLocator
SourceLocator, ,
DOM.
OutputKeys
,
.
923
TransformerConfigu
rationException
,
.
TransformerException ,
.
TransformerFactory
ConfigurationError
Transformer.
( ).
javax.xml.transform.dom.DOMLocator
DOMLocator ,
DOM. , ,
,
getLocator() Exception.
SourceLocator :
org.w3c.dom.Node getOriginatingNode()
,
.
javax.xml.transform.dom.DOMResult
DOMResult
, DOM.
Transformer.transform().
DOMResult Node (, , ,
Document Element, , , DocumentFragment),
.
Node DOM.
Node, Document,
getNode().
XSLT
DOM, . ,
getFeature(DOMResult.FEATURE) .
XSLT disableoutputesca
ping="yes",
, Result.
PI_DISABLE_OUTPUT_ESCAPING, ,
Result.
PI_ENABLE_OUTPUT_ESCAPING.
924
DOMResult Node,
String, .
:
DOMResult()
DOMResult(org.w3c.xml.Node)
org.w3c.dom.Node getNode()
,
.
String getSystemId()
void setNode(org.w3c.dom.Node) ,
. Document, Element
DocumentFragment.
void setSystemId(String)
javax.xml.transform.dom.DOMSource
DOMSource DOM Document Source,
.
DOMSource
Transformer.transform().
;
TransformerFactory.newTemplates().
setSystemId() URI ,
URI (,
document()). DOM
, .
DOMSource DOM,
Document. , DOMSource
, ,
; DOMSource
<xsl:stylesheet>. transform()
, Document, ,
, ,
transformNode() MSXML3. ,
,
, .
, , XSLT
.
XPath DOM
.
,
925
Java, c DOM.
, , .
SAX,
. DOM
,
, Microsoft MSXML API.
XSLT DOM.
, getFeature(DOMSource.FEATURE)
.
:
DOMSource()
DOMSource(Node)
DOMSource(Node, String)
Node getNode()
DOMSource
String getSystemId()
URI
void setNode(Node)
DOMSource
setSystemId(String)
URI
javax.xml.transform.ErrorListener
ErrorListener ;
, , ,
setErrorListener() TransformerFactory
Transformer. ErrorListener
, .
SAX ErrorHandler,
: , .
; ,
, , ,
; , ,
.
,
, ,
.
ErrorListener ,
System.err.
926
. [TE]
,
TransformerException, .
void error(TransformerException)
[TE]
void fatalError(TransformerException)
[TE]
void warning(TransformerException)
[TE]
javax.xml.transform.OutputKeys
,
,
<xsl:output> <xsl:document>.
:
CDATA_SECTION_ELEMENTS
DOCTYPE_PUBLIC
DOCTYPE_SYSTEM
ENCODING
INDENT
MEDIA_TYPE
METHOD
OMIT_XML_DECLARATION
STANDALONE
VERSION
<xsl:output>.
, getOutputProperty()
setOutputProperty() Transformer.
javax.xml.transform.Result
Result ;
SAXResult, DOMResult StreamResult,
XML.
Transformer.transform().
, PI_DISABLE_OUTPUT_ES
CAPING PI_ENABLE_OUTPUT_ESCAPING,
, disableoutput
escaping="yes" <xsl:text> <xsl:valueof> .
,
Result:
String getSystemId()
void setSystemId()
927
javax.xml.transform.sax.SAXResult
SAXResult
,
SAX2 ContentHandler SAX
, XML. SAXResult
ContentHandler, ,
. (
ContentHandler Locator,
, .)
XSLT
SAX, . ,
getFeature(SAXResult.FEATURE) .
,
XSLT ContentHandler:
disableoutputescaping? TrAX
, ,
disableoutputescaping="yes"
, Result.
PI_DISABLE_OUTPUT_ESCAPING, ,
Result.PI_ENABLE_OUTPUT_ESCAPING.
?
TrAX , SAXResult
LexicalHandler, ContentHandler.
LexicalHandler.
,
? SAX ContentHandler
,
, ContentHandler
. , 2, XSLT
. ,
TrAX . (,
Saxon, ,
, , ,
. ,
ContentHandler ,
SAXException, .
:
SAXResult()
SAXResult(org.xml.sax.ContentHandler)
928
org.xml.sax.ContentHandler getHandler()
ContentHandler
void setHandler(org.xml.sax.ContentHandler)
ContentHandler,
,
void setHandler(org.xml.sax.ext.LexicalHandler)
LexicalHandler,
( ),
void setSystemId()
javax.xml.transform.sax.SAXSource
SAXSource Source,
Transformer.transform() (
XML) TransformerFactory.newTemplates() (
).
, SAXSource SAX
(XMLReader) SAX InputSource,
URL, .
SAXSource SAX.
XML,
; , XMLReader /
InputSource, SAX ,
, SQL
LDAP.
XMLReader ,
.
javax.xml.parsers.SAXParserFactory,
, .
XSLT SAX.
, getFeature(SAXSource.FEATURE)
.
:
SAXSource()
SAXSource(InputSource)
SAXSource(XMLReader, InputSource)
929
InputSource getInputSource()
SAX InputSource.
String getSystemId()
,
URI.
XMLReader getXMLReader()
XMLReader (),
.
void setInputSource(org.xml.sax
.InputSource)
SAX InputSource.
void setSystemId(String)
,
URI.
void setXMLReader(XMLReader)
XMLReader ().
static org.xml.sax.InputSource
SAX In
sourceToInputSource(Source source) putSource TrAX Source .
, null.
javax.xml.transform.sax.SAXTransformerFactory
TransformerFactory,
:
SAX ContentHandler (
TemplatesHandler), SAX,
, Templates
.
SAX ContentHandler (
TemplatesHandler), SAX,
,
.
SAX XMLFilter,
: XMLFilter
SAX SAX, Transformer,
, XMLFilter. ,
.
,
, TrAX .
getFeature(SAXTransformerFactory.FEATURE) ,
TransformerFactory SAXTransformerFactory.
getFeature(SAXTransformerFactory.FEATURE_XMLFILTER)
, newXMLFilter().
SAXTransformerFactory,
TransformerFactory.newInstance().
930
TransformerFactory
:
TemplatesHandler
newTemplatesHandler()
[TCE]
TemplatesHandler. Templates
Handler
SAX, .
TransformerHandler
newTransformerHandler()
[TCE]
TransformerHandler. Transfor
merHandler
XML,
SAX.
TransformerHandler
newTransformerHandler
(Source)
[TCE]
TransformerHandler. Source
, .
TransformerHandler ,
,
XML, SAX.
TransformerHandler
newTransformerHandler
(Templates)
[TCE]
TransformerHandler. Templa
tes .
TransformerHandler ,
,
XML, SAX.
org.sax.xml.XMLFilter
newXMLFilter(Source)
[TCE]
XMLFilter. Source
, .
XMLFilter ,
.
org.sax.xml.XMLFilter
newXMLFilter(Templates)
[TCE]
XMLFilter. Templates
.
XMLFilter ,
.
javax.xml.transform.Source
Source ; :
SAXSource, DOMSource StreamSource,
XML.
Transformer.transform()
TransformerFactory.newTemplates().
,
Source :
String getSystemId()
void setSystemId()
931
javax.xml.transform.SourceLocator
SourceLocator , SAX Locator.
SourceLocator ,
. SourceLocator XSLT
,
TransformerException.getLocator().
:
int getColumnNumber()
,
, 1
int getLineNumber()
,
, 1
String getPublicId()
,
, null
String getSystemId()
,
, null
javax.xml.transform.stream.StreamSource
StreamSource XML
. SAX InputSource;
, StreamSource, ,
InputSource Source,
InputSource
Transformer.transform(Source, Result).
XSLT ,
, .
, getFeature(StreamSource.FEATURE) .
(InputStream) (Reader),
setSystemId() URI
, URI (, ,
document()).
, .
:
StreamSource()
StreamSource(java.io.File)
StreamSource(java.io.InputStream)
StreamSource(java.io.InputStream, String)
StreamSource(java.io.Reader)
StreamSource(java.io.Reader, String)
StreamSource(String)
932
,
,
setXXX(). String
.
:
java.io.InputStream getInputStream()
InputStream
String getPublicId()
java.io.Reader getReader()
Reader
String getSystemId()
void setReader(java.io.Reader)
Reader
void setSystemId(java.io.File)
File,
void setSystemId(String)
(URL)
javax.xml.transform.stream.StreamResult
,
StreamResult. XML, HTML
, ,
<xsl:output>, setOutputProperty() setOutputProperties()
Transformer.
StreamResult StreamSource, ,
, SAX InputSource. StreamResult
( URL Java
File), (Writer), (OutputStream).
XSLT ,
. ,
getFeature(StreamResult.FEATURE) .
URI, .
, , , URI file:,
FTP WebDAV1.
1
(Web
Distributed Authoring and Versioning, WebDAV). . .
933
, , , .
, ,
URI; , URI SAX
InputSource, ,
.
URI .
. , String,
(URL).
StreamResult()
StreamResult(File)
StreamResult(java.io.OutputStream)
StreamResult(String)
StreamResult(java.io.Writer)
java.io.OutputStream getOutputStream()
String getSystemId()
java.io.Writer getWriter()
Writer
)
void setOutputStream(java.io.OutputStream)
void setSystemId(java.io.File)
,
URL
void setSystemId(String)
, URL
void setWriter(java.io.Writer)
Writer (
),
javax.xml.transform.Templates
Templates .
,
, ,
. Templates
, Transformer,
newTransformer(), , (,
),
Transformer.transform().
934
Templates:
java.util.Properties
getOutputProperties()
Properties,
,
<xsl:output>.
,
OutputKeys; ,
. ,
, ,
: ,
<xsl:output>,
,
: XML HTML.
javax.xml.transform.sax.TemplatesHandler
TemplatesHandler SAX ContentHandler,
SAX .
, ,
getTemplates().
TransformerFactory.
newTemplates() SAX
Source. TemplatesHandler ,
SAX SAX XMLReader; ,
, SAX
TrAX Transformer. Templates
Handler SAXResult
Result .
TemplatesHandler
newTemplatesHandler(), SAXTransformerFactory.
, SAX ContentHandler,
:
String getSystemId()
.
URI (, <xsl:include>
<xsl:import>).
935
javax.xml.transform.TransformerFactoryConfigurationError
TransformerFactoryConfigurationError (, ,
, )
XSLT, .
, (Error), (Exception),
,
.
:
String getMessage()
Exception getException()
javax.xml.transform.Transformer
Transformer ,
Source Result.
, ,
, ErrorListener URIResolver.
IXSLProcessor
MSXML3 API Microsoft.
Transformer newTransfor
mer() Templates TransformerFactory.
Transformer
, :
, .
Transformer Templates.
transform(),
, (Source) (Result)
. Source
Result. .
. [IAE]
[TE] IllegalArgumentException TransformerException.
void clearParameters()
set
Parameter().
ErrorListener
getErrorListener()
ErrorListener .
936
java.util.Properties
getOutputProperties()
{IAE}
,
. ,
,
setOutputProperty() setOutputProperties().
String getOutputProperty(
String)
[IAE]
,
.
,
OutputKeys,
.
Object getParameter(String) ,
.
URIResolver getURIResolver() URIResolver,
, ,
.
void setErrorListener(
ErrorListener)
[IAE]
ErrorListener,
, .
void setOutputProperties(
java.util.Properties)
[IAE]
.
,
<xsl:output>. , ,
, OutputKeys,
,
, ,
,
.
{uri} , , .
void setOutputProperty(
String, String)
[IAE]
.
void setParameter(
String, Object)
.
,
<xsl:param>;
,
{uri} .
. ( ),
Java XPath ,
Java.
8.
937
void setURIResolver(
URIResolver)
URIResolver,
URI,
,
document().
void transform(
Source, Result)
[TE]
. Source
Result ,
Source Result .
javax.xml.transform.TransformerConfigurationException
,
. TransformerExcepti
on , .
, ,
, , XSLT
, .
javax.xml.transform.TransformerException
TransformerException ,
, .
:
, .
, ,
. ( ,
getException(),
Exception: Throwable, Ex
ception, Error.)
SourceLocator,
.
. , ,
.
, , ,
.
, ,
, XSLT,
.
:
Throwable getCause()
Throwable getException()
938
String getLocationAsString()
SourceLocator getLocator()
SourceLocator,
,
String getMessageAndLocation() ,
void initCause(Throwable)
printStackTrace(), Exception,
, ,
TransformerException, ,
Exception.
javax.xml.transform.TransformerFactory
SAXParserFactory DocumentBuilderFactory
javax.xml.parsers, ,
XSLT
.
,
TransformerFactory,
TransformerFactory.
newInstance(). XSLT
TransformerFactory,
,
. ,
:
javax.xml.parsers.TransformerFactory,
. ,
D java
System.setProperty() .
$JAVA_HOME/lib/jaxp.properties
javax.xml.
parsers.TransformerFactory.
API, JAR.
, XSLT ,
.jar,
. ,
,
CLASSPATH.
939
TransformerFactory,
. , , newTempla
tes() newTransformer()
Transformer (
) SAXParser.
. ,
,
. 914.
Source getAssociatedStyleSheet(Sour
ce, String media, String title, String
charset)
[TCE]
XML,
Source,
<?xmlstylesheet?>
,
media, title charset (
null),
Source, .
Object getAttribute(String)
[IAE]
,
.
ErrorListener getErrorListener()
ErrorListener,
. ,
ErrorListener .
boolean getFeature(String)
,
.
, , getFeature(SAXRe
sult.FEATURE) true,
SAX ContentHandler.
URIResolver getURIResolver()
URIResolver,
.
static TransformerFactory
newInstance()
[TFCE]
TransformerFactory
,
.
Templates newTemplates(Source)
[TCE]
,
Source, Templates,
.
Transformer newTransformer()
[TCE]
Transformer,
.
Transformer newTransformer(Source)
[TCE]
, newTemplates(
Source).newTransformer().
,
.
940
void setErrorListener(ErrorListener)
[IAE]
ErrorListener
.
void setURIResolver(URIResolver)
URIResolver URI,
.
javax.xml.transform.sax.TransformerHandler
TransformerHandler SAX,
.
Result.
TransformerHandler ,
SAX, ContentHandler, LexicalHandler DTDHandler.
LexicalHandler,
, DTDHan
dler, DTD,
DTD
.
TransformerHandler
Transformer SAXSource
. ,
SAX , SAX XMLReader. ,
TrAX,
, ContentHandler
.
TransformerHandler
newTransformerHandler() SAXTransformerFactory.
, SAX ContentHandler,
LexicalHandler DTDHandler, TransformerHandler
:
String getSystemId()
,
.
Transformer getTransformer()
Transformer,
.
void setResult(Result)
[IAE]
,
.
void setSystemId(String)
.
URI URI,
.
941
javax.xml.transform.URIResolver
URIResolver : ,
, setURIResolver()
TransformerFactory Transformer. XSLT
XML URI, <xsl:include>,
<xsl:import> document(),
URIResolver. URIResolver URI
, Source:
, SAXSource, DOMSource StreamSource.
, , :
document('db:employee=517541'), URIResolver
URI XML,
.
:
URI, ,
URI.
Source,
; ,
TransformerException.
null,
, URIResolver,
.
: ,
TrAX, : XSLT , ,
document()
URI, .
URIResolver URI
, URI ,
,
: URIResolver,
, URI ,
XSLT, .
, Ja
va java.net.URL.
,
API TrAX .
942
1:
(FileTransform.java) ;
,
.
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import java.io.File;
public class FileTransform {
public static void main(String[] args) throws Exception {
File source = new File(args[0]);
File style = new File(args[1]);
File out = new File(args[2]);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer t = factory.newTransformer(new StreamSource(style));
t.transform(new StreamSource(source), new StreamResult(out));
}
}
, TrAX.
Java, ,
Wrox .
, ,
. , XSLT,
TrAX, Saxon Xalan.
CLASSPATH .
, ,
, , ,
.
, Sun Java JDK,
:
javac FileTransform.java
, ,
. ,
:
java FileTransform source.xml style.xsl out.html
, .
,
,
. .
, TrAX,
Java.
943
,
, Java
XML XSL, source.xml style.xsl. ,
,
. , , Java
.
URI,
source.xml. JAXP 1.1
, Saxon, Xalan . ,
, , SAX
URI ,
InputSource, , SAX
URI.
2:
, Parameters.java,
:
System.out .
main() :
public static void main(String[] args) throws Exception {
File source = new File(args[0]);
File style = new File(args[1]);
String title = args[2];
TransformerFactory factory = TransformerFactory.newInstance();
Transformer t = factory.newTransformer(new StreamSource(style));
t.setParameter("title", title);
t.setOutputProperty(OutputKeys.INDENT, "no");
t.transform(new StreamSource(source), new StreamResult(System.out));
}
.
( , ).
java Parameters source.xml style.xsl "New organization structure"
, , HTML
, <title> <h1>
. , ,
.
944
3:
,
, .
,
,
, . ,
, .
DOM.
DocumentBuilder, ,
TrAX,
. TrAX
DOM: ,
DOM.
DOM,
. ,
, Templates.
(Repeat.java) :
public static void main(String[] args) throws Exception {
File source = new File(args[0]);
File style = new File(args[1]);
TransformerFactory factory = TransformerFactory.newInstance();
// DOM
//
Transformer builder = factory.newTransformer();
DOMResult result = new DOMResult();
builder.transform(new StreamSource(source), result);
Document doc = (Document)result.getNode();
//
Templates templates = factory.newTemplates(new StreamSource(style));
//
//
for (int i=2; i<args.length; i++) {
Transformer t = templates.newTransformer();
System.out.println("======= TITLE = " + args[i] + "=======");
t.setParameter("title", args[i]);
t.transform(new StreamSource(source), new StreamResult(System.out));
}
}
:
java Repeat source.xml style.xsl one two three four
945
, HTML
one, two, three four.
,
,
.
4:
<?xmlstylesheet?>
. , 3,
XML <?xmlstylesheet?>.
,
TrAX API,
getAssociatedStylesheet(), TransformerFactory.
main() (Associated.java):
public static void main(String[] args) throws Exception {
File input = new File(args[0]);
StreamSource source = new StreamSource(input);
TransformerFactory factory = TransformerFactory.newInstance();
// ,
Source style =
factory.getAssociatedStylesheet(source, null, null, null);
//
Transformer t = factory.newTransformer(style);
t.transform(source, new StreamResult(System.out));
}
5: SAX
XSLT
SAX. ,
946
SAX2 XMLFilter. ,
SAX2 ContentHandler (
SAX) .
XSLT, Java
.
(Pipeline.java) .
Java
, .
XSLT
, .
XML
.
,
. XML
, <b> <B> .
HTML ,
<b> <B> . XSLT
,
Java.
XML, Java.
SAX XMLFilterImpl.
startElement() endElement();
.
.
.
private class PreFilter extends XMLFilterImpl {
public void startElement (String uri, String localName, String qName,
Attributes atts)
throws SAXException {
String newLocalName = localName.toLowerCase();
String newQName = qName.toUpperCase();
AttributesImpl newAtts =
(atts.getLength()>0 ?
new AttributesImpl(atts) :
new AttributesImpl());
newAtts.addAttribute("", "oldlocalname",
"oldlocalname", "CDATA", localName);
newAtts.addAttribute("", "oldqname",
"oldqname", "CDATA", qName);
super.startElement(uri, newLocalName, newQName, newAtts);
}
public void endElement (String uri, String localName, String qName)
throws SAXException {
String newLocalName = localName.toLowerCase();
947
;
, startElement()
( ) ,
endElement .
private class PostFilter extends XMLFilterImpl {
public Stack stack;
public void startDocument() throws SAXException {
stack = new Stack();
super.startDocument();
}
public void startElement (String uri, String localName, String qName,
Attributes atts)
throws SAXException {
String originalLocalName = localName;
String originalQName = qName;
AttributesImpl newAtts = new AttributesImpl();
for (int i=0; i<atts.getLength(); i++) {
String name = atts.getQName(i);
String val = atts.getValue(i);
if (name.equals("oldlocalname")) {
originalLocalName = val;
} else if (name.equals("oldqname")) {
originalQName = val;
} else {
newAtts.addAttribute(
atts.getURI(i),
atts.getLocalName(i),
name,
atts.getType(i),
val);
}
}
super.startElement(uri, originalLocalName, originalQName, newAtts);
stack.push(originalLocalName);
stack.push(originalQName);
}
public void endElement (String uri, String localName, String qName)
throws SAXException {
String originalQName = (String)stack.pop();
String originalLocalName = (String)stack.pop();
super.endElement(uri, originalLocalName, originalQName);
}
}
948
, , ,
:
XML,
ParserFactory,
.
.
XSLT, ,
filter.xsl.
.
, TransformerFactory,
TransformerHandler,
StreamResult.
SAX2, XMLReader,
ContentHandler,
XMLFilter. setParent(),
, ContentHandler
XMLFilter setContentHandler(). , ,
parse()
XMLFilter, .
,
:
public void run(String input) throws Exception {
StreamSource source = new StreamSource(new File(input));
File style = new File("filter.xsl");
TransformerFactory factory = TransformerFactory.newInstance();
if (!factory.getFeature(SAXTransformerFactory.FEATURE_XMLFILTER)) {
System.err.println("SAX Filters are not supported");
} else {
SAXTransformerFactory saxFactory = (SAXTransformerFactory)factory;
XMLFilter pre = new PreFilter();
// SAX2
// SAXParserFactory
pre.setParent(new com.icl.saxon.aelfred.SAXDriver());
XMLFilter filter = saxFactory.newXMLFilter(new StreamSource(style));
filter.setParent(pre);
XMLFilter post = new PostFilter();
post.setParent(filter);
TransformerHandler serializer = saxFactory.newTransformerHandler();
serializer.setResult(new StreamResult(System.out));
Transformer trans = serializer.getTransformer();
trans.setOutputProperty(OutputKeys.METHOD, "xml");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
post.setContentHandler(serializer);
post.parse(source.getSystemId());
}
}
949
main():
public static void main(String[] args) throws Exception {
new Pipeline().run(args[0]);
}
:
java Pipeline mixedup.xml
JAXP 1.1.
JAXP SAX DOM,
javax.xml.parsers.
javax.xml.transform ,
API XML TrAX.
,
TrAX .
TrAX , Java
, XSLT
XSLT.
TrAX Saxon Xalan,
. ,
.
, .
XSLT XPath
XML ,
.
.
,
,
.
ID
XML
ID , (
ID). ID ,
. ID
,
(valid) ( XSLT
). ID
id(). IDREF
XSLT.
URI
Internet
XML Namespaces
URI, . URI
,
; URI .
URI ,
URL http:// ,
.
951
(Attribute)
(Attribute)
XML
=, ,
category="grocery".
XSLT
URI.
URI URI XML,
( , , ,
). URI
, , .
URI xml:base. URI
URI,
, , URI href
URI .
(Embedded Stylesheet)
XSLT
, XML
,
XML ( XML) <xsl:stylesheet>.
(Temporary Tree)
,
<xsl:variable>. XSLT 1.0 (
) . XSLT 1.1
,
, .
XSLT
, ,
,
.
(Expression)
XPath
XPath, , ,
, .
, select <xsl:foreach>,
<xsl:valueof> <xsl:variable>, test <xsl:if>
<xsl:when>. ,
.
(Path Expression)
XPath
,
. ,
, ,
952
.
,
. , ./parent::*
. ,
.
(Global Variable)
XSLT
, <xsl:variable> .
,
.
(Tree)
XPath
,
XML. (,
).
XML
, , , .
(Document)
XML
, XML Document,
(wellformed) , , ,
,
, (valid).
(Named Template)
XSLT
<xsl:template>, name.
<xsl:calltemplate>.
(Instruction)
XSLT
XSLT,
, <xsl:variable>, <xsl:choose> <xsl:message>.
XSLT , , <xsl:param>
<xsl:when> ,
.
(Processing Instruction)
XML
XML,
, .
<? ?>. , , XML
,
.
(Source Document)
(Source Document)
953
XPath
XML,
. document()
.
(Comment)
XML
XML,
, .
<! >.
(Result Tree)
XSLT
.
.
, .
, ,
.
(Literal Result Element)
XSLT
,
, XSLT
. ,
,
, , (
).
(Context Node)
XPath
XPath,
(, select <xsl:valueof>
, ),
, . XPath,
, ,
.
..
(Root Node)
XPath
.
XML,
,
. (,
) , ,
: ,
(wellbalanced).
.
954
(Wellformed)
XML
,
, XML.
, ,
. XSLT
, .
(Boolean)
XPath
XPath .
.
(Local Variable)
XSLT
, .
, <xsl:variable>,
, ,
.
.
(Output Method)
XSLT
(Attribute Set)
XSLT
<xsl:attribute>, ,
useattributesets <xsl:element>
<xsl:copy>, xsl:useattributesets
,
.
(Nodeset)
XPath
. ,
, .
(Unparsed Entity)
XML
,
.
, ,
, XML. unparsedentityuri() XSLT
,
.
5 (NaN)
(NaN)
955
XPath
(NotaNumber, NaN). ,
, .
, , number('').
(Pattern)
XSLT
, ,
, .
XPath. XSLT:
<xsl:template>, <xsl:key> <xsl:number>.
(Namespace Declaration)
XML Namespaces
, XML, ,
,
URI, .
: xmlns="uri"
, ( ),
xmlns:prefix="uri" .
XML ,
, , , .
(Default Namespace Declaration)
XML
XML xmlns="uri".
, ,
, URI
.
, (, ), URI
.
(Document Type Definition, DTD)
XML
XML XML.
, ,
, .
XPath
.
. attribute
, namespace .
, *:
, followingsiblings::* ,
namespace::* .
956
(Axis)
XPath
.
, ,
. , ancestor ,
,
followingsibling ,
.
XPath
ancestor : ,
.
.
XPath
ancestororself
ancestor. .
XPath
attribute .
, .
XPath
child .
, ,
, .
XPath
descendant ,
.
XPath
descendantorself ,
descendant.
XPath
following , ,
,
. .
XPath
followingsibling ,
.
.
957
XPath
namespace ,
. ,
. ,
, ,
,
, .
XPath
preceding ,
, , ,
, .
XPath
precedingsibling ,
, .
.
(Parameter)
XSLT
, .
,
( )
.
<xsl:template>,
<xsl:applytemplates> <xsl:calltemplate>.
(Instantiate)
XSLT
XSLT , ,
,
(instantiate). ,
, .
(QName)
XML Namespaces
(Context Position)
XPath
XPath, ,
, . XPath,
,
,
.
958
, position(),
, [1].
(Document Order)
XPath
.
,
, .
, , , ,
. ,
, .
(Predicate)
XPath
,
, .
,
, ,
, [1] .
(Precedence)
XSLT
. .
(Import Precedence)
XSLT
, <xsl:import>,
.
,
. ,
, ,
.
(Prefix)
XML Namespaces
. .
(Namespace Prefix)
XML Namespaces
,
,
( ,
).
,
.
(Priority)
(Priority)
959
XSLT
.
.
priority <xsl:template>; ,
.
,
: ,
.
(Whitespace)
XML
, , .
,
.
(Namespace)
XML Namespaces
.
URI,
, .
, ;
.
( XML, , ,
. .) ,
,
.
(Context Size)
XPath
XPath, ,
.
XPath, ,
,
. ,
last().
(Expanded Name)
XML Namespaces
,
URI ,
. : URI
.
, , TrAX,
{uri}.
960
(Mode)
XSLT
,
. , <xsl:applytemplates>,
, <xsl:template>.
(Wellbalanced)
XML ,
.
:
,
. XSLT XPath ,
, XML.
XML XSLT ;
(external general
parsed entity).
(Variable Binding)
XPath
<xsl:variable> <xsl:param>
.
XML
XML,
<![CDATA[ ]]>; CDATA
, , ]]>.
(Variable Reference)
XPath
$name , .
(Character Reference)
XML
Unicode, ↤.
, .
(Entity Reference)
XML
, ,
&name;.
(Stringvalue)
XPath
.
,
(
, , ).
<xsl:valueof select=".">.
961
(String)
(String)
XPath
, XPath.
, Unicode (
, XML).
(Entity)
XML
,
XML.
, , ,
. (parsed entity)
XML, (unparsed enti
ty) . (general entity)
, ,
(parameter entity)
(DTD).
(Stylesheet)
XSLT
<xsl:stylesheet> (
), ,
<xsl:include> <xsl:import> (
).
(Text Node)
XPath
, ( XML
PCDATA) XML.
. ,
, .
(Current Output Destination)
XSLT , , <xsl:valueof>
<xsl:element>, . ,
<xsl:variable>, ,
, ,
. ,
, .
XSLT 1.1 ( XSLT 1.0,
)
.
XSLT
<xsl:applytemplates>
,
.
962
<xsl:calltemplate>, <xsl:foreach>.
,
<xsl:applyimports>.
XSLT
( )
.
select <xsl:applytemplates> <xsl:foreach>.
, , <xsl:sort>.
XPath
(,
position()),
(, last()).
(Current Node)
XSLT
,
<xsl:applytemplates> <xsl:foreach>.
current().
,
, , ,
, ..
(Template Body)
XSLT, ,
,
<xsl:template> .
,
,
. XSLT
(Template);
(Template Body),
<xsl:template>.
(Node)
XPath
. : ,
, , ,
, .
(Attribute Node)
XPath
, XML. ,
,
, ,
. ,
963
(DTD). .
(Processing Instruction Node)
XPath
, XML.
(Comment Node)
XPath
, XML.
.
(Namespace Node)
XPath
,
URI. ,
: ,
.
(Element Node)
XPath
, XML.
,
, , ,
, ,
XML.
(Simplified Stylesheet)
, XSLT
(Literal Result Element as Stylesheet
Facility). ,
,
.
XSLT
XSLT 1.0
,
<xsl:variable>. XSLT 1.1
,
.
(Function)
XPath
, XPath;
. XPath
, .
964
, XPath XSLT,
, .
(Extension Function)
XSLT
, ,
, XPath.
XSLT , , ,
.
(Number)
XPath
, XPath.
, IEEE 754.
XSLT
, ,
, .
,
: , file="{$dir}/{$fna
me}.html" file="out/page.html",
$dir $fname out page, .
, XSLT,
, .
(Template Rule)
XSLT
<xsl:template> , match.
<xsl:applytemplates>;
, ,
.
(Step)
XPath
XPath
. ,
; ,
, ,
.
(Element)
XML
XML,
, <>Wrox Press</>;
, <
="Wrox"/>.
(Top5level Element)
(Toplevel Element)
965
XSLT
,
<xsl:stylesheet>.
(Document Element)
XML
, ,
. XML
,
XPath,
.
(Extension Element)
XSLT
, ,
, ,
, XSLT. XSLT ,
, , .
(), 108
( ), 392
( ),
108, 459
!= ( ), 105, 108,
410
, 411
, 411
, 414
not(), 579
$ (
), 456
& ()
HTML URL, 313
HTML,
312
, 362
>, , 405
<, , 404
  ( ), 267, 365
HTML, 313
, 358
* ( ), 421,
437
* ( ), 108, 428, 436
+ ( ), 392
+ (), 108
. ( ), 453
.. ( ), 453
/ ( )
, 479
, 390
/ ( ), 101, 408, 438
, 481
// ( ), 408, 438, 449, 450
, 481
:: (
), 102
:: ( ), 455
< ( ), 108, 404
,
110
, 405
<, <,
404
<= ( ), 108,
404
, 405
= ( ), 105, 108, 410
, 411
, 411
, 414
=>, , 404
@ ( ::), 102,
452
{} ( )
, 148
| ( ), 403
, 477
, 503
, 414
> ( ), 108, 404
,
110
, 405
>, >,
405
>= ( ), 108
, 405
0 ( ), 106
4XSLT
,
890
967
XML,
Python, 890
FourThought, 890
A
<a> ( )
HTML, 540
abort(),
IXMLDOMDocument, 796
Activated Intelligence
EZ/X, 892
addParameter(),
IXSLProcessor, 804
lfred (
XML)
Saxon,
28
Altova
XML Spy, 903
ancestor, , 430
ancestororself, , 430
ANSEL
Unicode, 733
Apache, 860
API, 24
DOM, 25
SAX, 25
TrAX
. TrAX API
Oracle,
814
Saxon, 833
JAXP 1.1, 914
SAXResult, 927
ErrorListener, 925
Result, 926
Source, 930
SourceLocator, 931
URIResolver, 941
DOMLocator, 923
DOMResult, 923
DOMSource, 924
OutputKeys, 926
SAXSource, 928
SAXTransformerFactory,
929
StreamResult, 932
StreamSource, 931
Templates, 933
API
JAXP 1.1
TemplatesHandler, 934
Transformer, 935
TransformerConfigura
tionException, 937
TransformerException,
937
TransformerFactory, 938
TransformerFactoryCon
figurationError, 935
TransformerHandler, 940
,
921
, 921
DOM, 917
DocumentBuilder, 919
DocumentBuilderFacto
ry, 918
SAX, 914
SAXParser, 916
SAXParserFactory, 915
ASP, 318, 363
attribute, , 430
C
CDATA
XML, 84
child, , 431
clone(),
IXMLDOMSelection, 803
Cocoon
XSP, 892
Apache, 892
XalanJava 2, 872
COM
msxsl:script, 755
ContentHandler ( SAX)
, 67
createProcessor(),
HTML, ,
731
IXSLTemplate, 806
Crimson, XML
jd:xslt, 895
CSS
CSS2, 41
, 41
, 41
968
D
#default
excluderesultprefixes, 345
descendant, , 431
descendantorself, , 431
disableoutputescaping
xsl:transform, 369
div ( ), 108, 428
<!DOCTYPE>
HTML, 314
XML, 311
DocumentHandler ( SAX)
, 67
DOM
. API
XPath, 65
XPath, 37
, 315
, 25
XPath, 68
,
DOM, 623
DSSSL
SGML , 43
, 665
SGML, 43
, 44
DTD
XML, 309
, 82
XML Schema,
56
, 90
, 40
ID, 81
ID, 90
expat, XML
Sablotron, 896
EZ/X, Activated Intelligence, 892
F
following, , 431
followingsibling, , 431
FOP (
)
Saxon, 829, 858
foreach, 107
G
getContextNode(),
XSLTContext, Java, 642
getContextPosition(),
XSLTContext, Java, 643
getContextSize(),
XSLTContext, Java, 643
getCurrentNode(),
XSLTContext, Java, 643
getOwnerDocument(),
XSLTContext, Java, 643
getProperty(),
IXMLDOMSelection, 803
Ginger Alliance
Sablotron, 895
H
HTML
XML,
XSLT, 22
, 688
xsl:applytemplates, 689
xsl:calltemplate, 689
, 729
createProcessor(), 731
transform(), 731
init(), 731
refresh(), 731
ECMAScript
, 153
EntityResolver
Saxon, 834
Excelon
Stylus Studio, 896
969
IdKeyPattern
, 489
, 488
IEEE 754, , 392, 405, 429
, 459
, 106
InfoSet
.
XML
Infoteria
iXSLT, 893
Inlogix
XESALT, 903
Instant Saxon, 828
Internet Explorer 5.x
WDxsl, 28
MSXSL, 37
XSLT, 38
ISO 3166, , 556
ISO 639, , 555
iso88591
, 265, 315
item(),
IXMLDOMNodeList, 802
IXMLDOMSelection, 803
IXMLDOMDocument,
load(), 796
loadXML(), 796
save(), 796
setProperty(), 797
validate(), 797
, 798
IXMLDOMNode,
selectNodes(), 799
selectSingleNodes(), 800
transformNode(), 800
transformNodeToObject(), 800
, 799
IXMLDOMNodeList,
item(), 802
nextNode(), 802
reset(), 802
, 802
IXMLDOMParseError,
, 802
IXMLDOMSelection,
clone(), 803
getProperty(), 803
item(), 803
nextNode(), 803
reset(), 803
, 804
IXSLProcessor,
addParameter(), 804
reset(), 804
setStartMode(), 804
transform(), 804
, 805
iXSLT
Infoteria, 893
IXSLTemplate,
createProcessor(), 806
J
Java
, 154
Java Server Pages, 318, 363
JavaScript
, 155
JavaScript, , 645
functionavailable(), , 649
, 646
XSLT
XPath, 648
XSLTContext, 648
, 647
, 649
, 646
JavaScript,
, 624
Java
, 625
JAXP 1.1 API, Saxon
. API
jd:xslt, 894
JScript,
msxsl:script, 754
L
load(),
IXMLDOMDocument, 796
loadXML(),
IXMLDOMDocument, 796
LotusXSL, 860
Xalan, 28
970
M
Microsoft, . MSXML3
MIME, 512
MML (Music Markup Language
), 22
mod ( ),
108, 428
MSXML3, 47, 751
DOM, 621
SDK (
), 758
XSLT, 27
,
771
XML, 751
Xpath, 751
XSLT, 751
, 794
,
792
XML
, 780
XSLT, 781
, 29
XML XSLT,
767
xsl:message, 757
,
, 781
CAB, 38
,
MSDN, 758
<object>
XML, 778
, 761
<?xmlstylesheet?>,
761
XPath
DOM, 785
,
786
ASP
JScript, 787
VBScript, 787
MSXML3
ASP
XSLT
, 788
ASP
, 791
, 790
, 791
XML, 779
IE5, 762
transformNodeToObject(), 773
, 757
,
757
parseError
, 768
XSLTemplate, 777
, 757
, 764
, 772
transformNode(), 772
XSLT, 763
<?xmlstylesheet?>, 764
, 768
JScript, 769
VBScript Visual Basic, 769
async, 771
<object>, 778
XSL
, 766
: ,
795
XSLT
, 766
MSXML
, 767
JScript, 767
VBScript, 767
, 758
, 758
971
MSXSL
XSLT
1.0, 37
MusicML, 22
MusicXML, 22
N
namespace, , 431
NaN (), 106
, 405
sum(), 109
, 955
null SQL, 108
, 333
, 107
nextNode(),
IXMLDOMNodeList, 802
IXMLDOMSelection, 803
node()
, 474
nodeset()
Oracle, 818
MSXML3,
756
null
XPath null
SQL, 105
null, , 77
O
<object>, HTML MSXML3, 778
or (), 402
Oracle, 808
Java XSLT, 813
API , 814
,
813
, 821
, 823
XML, 812
Oracle
XSQL, 810
, 826
API TrAX, 814
XML, 809
XPath DOM, 824
Oracle XML SQL, 811
nodeset(), 818
oracle:output,
819
Oracle 9i
XML, 27
P
parent, , 431
PDF (
), 66
preceding, , 431
precedingsibling, , 432
Programmer's File Editor
Saxon, 830
PSVI (postschemavalidation infoset
), 41
pull processing
.
push processing
.
Q
QName, 74
Quilt
XQuery, 56
R
reset(),
IXMLDOMNodeList, 802
IXMLDOMSelection, 803
IXSLProcessor, 804
RTF (
), 66
S
Sablotron
Ginger Alliance, 895
save(),
IXMLDOMDocument, 796
SAX
, 315
, 67
, 25
SAX2 ContentHandler
Saxon, 841
Saxon, 828
XHTML, 858
XSLT, 27
, 842
972
Saxon
XPath, 621
, 842
, 851
Saxon, 829
Java
, 833
XPath,
837
, 841
setAttribute()
, 835
TrAX API, 724
, 830
,
512
, 857
, 830
, 684
, 838
DOM, 836
EntityResolver,
834
, 829
SAX2, 840
, 838
, 842
StyleElement, 840
SDK (
)
MSXML3, 758
selectNodes(),
IXMLDOMNode, 799
selectSingleNodes(),
IXMLDOMNode, 800
self, , 432
setProperty(),
IXMLDOMDocument, 797
setStartMode(),
IXSLProcessor, 804
SGML, XML, 42
SQL Server 2000
XML, 27
SQL, XSLT, 26
standalone,
, 88
StoneBroom,
XSLTransform, 794
stringValue(),
XSLTContext, Java, 643
XSLTContext, JavaScript,
648
Stylus Studio, Excelon, 896
SVG (Scalable Vector Graphics
), 23, 24
systemProperty(),
XSLTContext, Java, 643
XSLTContext, JavaScript,
648
systemproperty(),
MSXML3, 756
T
tbug
Saxon, 831
transform(),
HTML, ,
731
IXSLProcessor, 804
TransformerException (TrAX), ,
937
TransformerFactory (TrAX), , 939
Transformiix, 714
Mozilla, 898
transformNode(),
IXMLDOMNode, 800
, MSXML3, 772
transformNodeToObject(),
MSXML3, 773
IXMLDOMNode, 800
MSXML3, 773
TrAX API
. API
JAXP 1.1
. API: TraX
,
Saxon Xalan, 28
Saxon, 829
Xalan, 864
, 914
, 921
973
TrAX API
Xalan, 861
<?xmlstylesheet?>,
945
SAX, 945
, 943
, 942
, 944
U
UltraEdit
Saxon, 830
UML, , 73
Unicode
contains(), 502
, 109
, 594, 596
, 294
XPath, 83
, 333
(),
110, 594, 596, 612
xsl:number, 293
Unicorn
, 900
Unicorn Enterprises, 899
, 684
, 902
, 901
Unicorn Enterprises
Unicorn, 899
URI (Uniform Resource Identifier)
escape HTML
, 312
URI, 511
URI, 511
, 269
xsl:document, 234
,
257
, 39
, 510
, 950
URI, 511
URI , 74
URI,
79
, 950
, 79
, 79
URL (Uniform Resource Locator)
URI, 510
UTF8
, 315
V
validate(),
IXMLDOMDocument, 797
VBScript
msxsl:script,
754
VoxML (Voice Markup Language
), 24
W
W3C, XSLT, 42
WDxsl
XSLT Microsoft,
28
XSLT, 752
, 751
MSXML3, 752
IE5, 763
, 751
X
<?xmlstylesheet?>
Oracle XSQL, 811
Xalan, 864
Xalan
XSLT, 27
TrAX API, 724
, 860
Apache, 860
Xerces, 861
XalanC++, 886
, 886
Unicode, 888
, 888
974
XalanJava 2, 861
XalanJava
, 862
Xalan Java,
864
, 862
Xalan, 884
STree,
866
XPath
Java, 867
, 880
,
882
, 882
SQL, 881
, 872
Java, 873
xalan:component, 874
xalan:script, 875
DOM, 866
XPath/Java
, 876
, 861
XalanJava
, 869
, 871
XDK
. Oracle
XESALT
Inlogix, 903
, 903
XHTML, Saxon, 858
XML
, 21
, 83
HTML,
XSLT, 22
, 21
XML Information Set
.
XML
XML Schema, , 334
XML Spy
Saxon, 829
Altova, 903
xmlinst.exe
MSXML3, 758
XML
Crimson, jd:xslt, 895
expat, Sablotron,
896
XML
MSXML3, 780
, 85
, 63
, 74
, 86
HTML
, 713
, 89
XML
XML, 310
, 72, 326, 424
XML, 90
, 56
XSLT, 40
Oracle, 809
XPath
XSLT, 36
, 36
Java, 625
Java, 625
XPointer, 37
XQuery, 37
DOM, 37
, 388
XSLT, 37
, 37
,
37
Oracle, 824
, 386
, 387
, 387
, 388
XPath
, 101
XPath
, 108
XPointer
XPath, 37
XSLT
XPath, 36
XQuery, 56
XPath, 37
XSL
, 42
SGML, 42
DSSSL, 45
, 45
, 42
, 46
DSSSL CSS, 46
, 46
, 47
XSL Composer
HTML, 906
Whitehill Technologies, 906
XSLFO
. XSL
XSLProcessor, (Oracle), 815
XSLStylesheet, (Oracle), 815
XSLT
XML, , 48
, 57
, 59
, 57
XML, 40
, 651
,
, 685
, 685
, 685
, 20
XPointer
XPath, 36
, 21
DTD, 40
XML, 25
XML
, 24
, 24
975
XML, 25
XSLT 1.0
MSXSL , 37
XSLT 1.1
, 55
, 54
, 55
, 47
XSLT SQL
XPath
SQL SELECT, 26
, 26
, 27
, 27
, 26
XSLT XPath
, 708
XSLT , 48
SGML, 48
XSL, 35
XML, 48
, 20
, 63
, 25
, 63
, 49
, 51
, 50
DSSSL, 43
, 20
XML, 20
, 20
,
51
XSLT XSLFO
, 42
XSLT,
, 243
XSLTC
Sun, 907
XSLTContext, Java, 642
getContextNode(), , 642
getCurrentNode(), , 643
getOwner(), , 643
int getContextPosition(), , 643
int getContextSize(), , 643
976
XSLTContext, Java
stringValue(), , 643
systemProperty(), , 643
, 643
XSLTContext, JavaScript
stringValue(), , 648
systemProperty(), , 648
XSLT 1998
. WDxsl
XSLT,
, 63
XSLT
MSXML3, 27
, 29
Saxon, 27
, 27
Xalan, 27
, 65
, 63
, 27
XSP
Cocoon, 892
XSQL, (Oracle), 810
xt
, 909
XSLT 1.0, 908
, 156
(James
Clark), 908
, 910
XML, 911
, 911
,
910
, 912
, 912
, 910
, 251
, 663
XPath
, 108
xsl:calltemplate, 205
, 66
XML
lfred, Saxon, 829
Crimson
Xerces, 871
Xerces
Xalan, 861
, 871
,
163
, 84
Oracle, 809
XPath, 393
, 392,
429
caseorder
xsl:sort, 333
charset,
<?xmlstylesheet?>, 125
count
xsl:number, 471
datatype
xsl:sort, 333
disableoutputescaping
xsl:copyof, 222
xsl:text, 363
xsl:valueof, 368
encoding
HTML, 313
, 314
excluderesultprefixes
, 258
,
269
xsl:stylesheet, 124, 144,
342, 348
extensionelementprefixes
, 258, 269
element
available(), 526
xsl:stylesheet, 124, 137,
144, 156, 244, 341, 347
format
xsl:number
, 152
from
xsl:number, 471
href,
<?xmlstylesheet?>, 124, 125
ID, 546
XML, 540
, 950
id
xsl:stylesheet, 123, 339,
346
IDREF, 82, 546
XML, 540
IDREFS, 82, 546
lang
xsl:number, 295
, 152
xsl:sort, 333
, 152
match
xsl:key, 471
xsl:template, 90, 351,
471
media,
<?xmlstylesheet?>, 125
method
xsl:output
, 152
mode
xsl:applytemplates, 181
xsl:template, 354
name
xsl:template
, 352
namespace
xsl:attribute, 192
priority
, 352
xsl:template
, 352
, 99
, 99
select
xsl:foreach, 249
standalone
XML, 307, 310
title,
<?xmlstylesheet?>, 125
type,
<?xmlstylesheet?>, 124, 125
977
useattributesets, 201
xsl:element, 240
xsl:attributeset, 199
version
xsl:stylesheet, , 527, 536
, 258
,
269
XML, 309
xsl:stylesheet, 123, 244,
340, 347
xml:base, 75, 512
xsl:include, 269
,
151
XSLT 1.1, 55, 151
xml:lang, 555
, 258
,
269
, 151
xml:space, 91, 162, 164, 322
, 258
, 135
,
269
,
361
, 151
xsl:preservespace
xsl:stripspace, 323
xsl:excluderesultprefixes, 138,
144, 157, 158, 345, 349
, 146
, 145
xsl:extensionelementprefixes, 137,
139, 144, 244, 341
element
available(), 526
xsl:stylesheet, 156
, 137
978
xsl:useattributesets, 139
xsl:version, 139, 244
,
132
,
, 84
DTD, 72
, 951
xsl:attribute, 196
xsl:attribute, 195
xsl:element, 241
, 76
Mozilla, 714
Netscape, 714
, 207
MSXML, 752
XML, , 88
, 244
,
109
, 333
,
, 116
, 337, 339
, 951
xsl:stylesheet, 346
, 70
Java, Saxon, 838
JavaScript,
Saxon, 838
XPath,
Java, 632
, 447
,
632
, 100
, 395
, 111
URI , 512
XSLT 1.1,
173
, 84
XSLT 1.0, 225
, 113
xsl:apply
templates, 183
, 222
, 951
<, >, <=, >=, 406
, 126
, 127
Saxon, 128
, 183
, 93,
98, 181
xsl:applytemplates, 98
, 951
HTML, 66
, 311
XHTML, 311
XML, 66
, 309
, 308
xsl:output, 305
, xsl:valueof, 155
, xsl:apply
templates, 184
, xsl:number, 295
, 360
, 66
xsl:output, 314
, 238
, 325
, 360, 367
, 237
, 394
, 395
XPath
, 393
, 99
, 172
, 951
XPath, 101
XPath, 386
. XPath
.
AbbreviatedAbsoluteLocationPath,
449
AbbreviatedAxisSpecifier, 452
AbbreviatedRelativeLocationPath,
450
AbbreviatedStep, 453
AbsoluteLocationPath, 390
AdditiveExpr, 391
AndExpr, 400
Argument, 392
AxisName, 430
AxisSpecifier, 455
EqualityExpr, 409
Expr, 396
FilterExpr, 460
FunctionCall, 394
LocationPath, 427
MultiplicativeExpr, 428
NameTest, 420
, 423
NodeTest, 422
, 483
, 422
OrExpr, 401
PathExpr, 407
, 408
, 407
979
XPath
Predicate, 443
, 484
, 443
PredicateExpr, 446
, 447
, 446
PrimaryExpr, 439
, 440
, 439
QName, 440
RelationalExpr, 404
RelativeLocationPath, 437
Step, 465
UnaryExpr, 459
UnionExpr, 402
VariableReference, 456
, 390,
427
, 391
, 392
, 394
, 396
, 400
, 401
, 404
, 407
, 408
, 407
, 409
, 402
, 420
, 422
comment(), 423
node(), 423
processinginstruction(), 423
text(), 423
, 483
, 422
, 427
,
428
, 430
,
427, 437
, 439
, 440
, 440
, 74
, 957
980
XPath, 386
, 443
, 484
, 484
, 443, 445
, 446
, 447
, 449
, 450
,
452
, 453
, 455
, 483
, 456
, 459
, 460
, 465
, 964
, 466
XPath
.
MSXML3 DOM, 785
XSLT, 26
XSLT, 397
, 393
XSLT, 26
W3C, 26
, 386
, 399
, 411
, , 414
, 411
, 413
,
398
, 668
,
, 671
,
679
, 667
, 668
, 664
, 665
, 101
, 951
XHTML, 67
, 66
, 663
, 663
, 673
, 391
xsl:sort, 719
xsl:element, 240
xsl:element, 241
,
718
, 115
, 957
, 99, 371
, 372
, 952
, 100, 316
, 318
, 651,
658, 663
,
655
, 652
( ),
294
, 678
, 682
, 682
, 380
, 683
generateid(),
552
, 553
, 552
981
generateid(),
543
, , 543
, 91
.
, 428
, 106, 429
, 65
, 952
XPath, 621
,
formatnumber(), , 534
XML
XML, 309
UML ,
77
, 103, 399
,
, 952
XML
, 69
, 394
, 100
, 535, 537
, 71
, 70
DOM, 68
,
80
, 72
, 71
, 72
, 72
, 72
, 72
, 72
, 84
, 295
, 690
xsl:text, 693
, 696, 697
, 707
, 83
, 64
XSLT SQL, 27
, , 582
, 65
, 512
generateid(),
543
, 97, 185
XSLT, 80
, 359
, 952
xsl:template, 350
, 119
xsl:applyimports, 174
NCName, 416
QName, 440
, xsl:attribute, 192
, 416
, 440
, 80
, 73
, 74
, 80
, 669
982
, 666
<?xmlstylesheet?>, 114, 115, 339
href, 124
type, 124
, 124
, 30
charset, 125
href, 125
media, 125
title, 125
type, 125
,
125
HTML, 312
, 325
, 91, 326
, 172
, 91, 952
, 244
XSLT
, 136
xsl:applyimports, 136
xsl:applytemplates, 136
xsl:attribute, 136
xsl:calltemplate, 136
xsl:choose, 136
xsl:comment, 136
xsl:copy, 136
xsl:copyof, 136
xsl:element, 136
xsl:fallback, 136
xsl:foreach, 136
xsl:if, 136
xsl:message, 136
xsl:number, 136
xsl:processinginstruction, 136
xsl:text, 136
xsl:valueof, 136
xsl:variable, 136
XML, 85
XSLT, 40
, 41
, 85
,
, 83
MSXML,
ProgID ClassID,
, 759
, 147
xsl:namespacealias, 147
XSL, ,
47
, , 953
,
381
, 670
, 109, 425
XML, 86
LDAP, 65
, , ,
576
,
550
, 275
, 277
, 279
, 280
, 278
, 272
, 277
XML, 309
, 88
, , 588
, 215
, 91, 217
, 953
Saxon, 841
, 953
, 141
, 138
xsl:attributesets, 143
xsl:excluderesultprefixes,
138
xsl:extensionelement
prefixes, 139
xsl:useattributesets, 139,
143
xsl:version, 139
, 142
, 143
, , 140
, 140
xsl:attribute, 143
, 132
, 144
, 144
,
, 144
, 143
, 106
983
, 64
, 64
, 172
, 953
, , 399
,
151
, 102
,
last(), , 559
position(), , 582
, 444, 462
,
xsl:variable, 375
, 444, 462
(.), 453
, 953
() , 671
, 83
xsl:attribute, 195
xsl:copy, 217
, 70, 71
URI, 75
, 98
, 390
, 390
, 449
, 73
, 953
,
, 503
, 76
, 75
. ,
XML, 305
, 954
MSXML3, 795
MSXML3, 794
984
XPath, 468
XPath
. XPath
.
Digits, 463
ExprToken, 468
, 469
ExprWhitespace, 447
FunctionName, 419
Literal, 424
MultiplyOperator, 436
NCName, 416
NCNameChar, 417
NodeType, 458
Number, 464
Operator, 435
OperatorName, 418
, 416
, 418
, 419
, 424
, 435
, 436
, 469
,
447
, 417
, 458
, 463
, 464
, 468
, 425
, 426
, 529, 613
, 100
, 954
XPath
Java, 630
,
lang(), , 557
, 295
xsl:decimalformat, 229
, 283
, 99, 371
, 372
, 954
(), 74
, 100, 316
, 318
,
, 208
, 390, 427
, 427, 437, 450
Java
, 626
XPath, 627
, 627
, 66
, 954
,
, 208
, 278
, 677
, 380
,
elementavailable(), 523
xsl:document, 236
xsl:key, 274
,
68
XML, 710
, 63
, 65
DOM, XPath
XSLT, 621
DOM
,
XPath XSLT,
621
, 123
, 119
( ), 68
XML,
, 22
, , 552
985
, 201
xsl:copy, 218
xsl:element, 238
, 198, 954
, 443
,
402
= !=, 411
, 954
, 503
, 403
, 503
, 403
<, >,
<=, >=, 405
, 100, 110
XPath
Java, 631
, 657
, 657
, 657
, 655
xsl:foreach, 250
xsl:apply
templates, 180
,
683
, 954
XSL
, 137
, 267, 365
HTML, 313
, 162
, 358
Oracle, 819
Xalan, 882
, 68
. NaN
, 955
,
109
, 333
, 83
, 106
, 106
, 108
, 163
, 424
, 83, 163
Unicode, 109
, 72
MSXML3, 757
xsl:attributeset, 201
(), 372
, 957
XSLT
, 766
MSMXL
JScript, 767
VBScript, 767
MSXML3, 757
, 162
, 162
, 168
, 167
XSLT, 163
XML, 163
normalizespace(), 164
,
, 166
986
,
, 210
, , 95
, 96
, 96
, ,
63, 185, 355
formatnumber(), 228
, 471
ChildOrAttributeAxisSpecifier, 487
, 488
, 487
IdKeyPattern, 488
LocationPathPattern, 478
Pattern
, 478
, 477
RelativePathPattern, 480
StepPattern, 482
, 486
, 482
, 477
, 478
ID, 488
, 489
, 478
, 480
, 480
, 481
, 482
, 486
ChildAt
tribute, 487
match xsl:template, 351
XPath,
472
, 90
, 280
id(), 488
key(), 484, 488
last(), 485
position(), 485
, 475
, 475
, 172
, 955
, 473
, 476
XSLT, 471
,
475
, 490
, 471
, 476
, 476
, 484
, 475, 484
, 484
current(),
484
, 485
, 473
, 474
position() , 475
,
, 514
, (|)
, 503
IXMLDOMDocument
abort(), 796
, 795
IXMLDOMDocument2
, 795
IXMLDOMNode
, 801
IXSLTemplate
, 806
parseError
MSXML3
, 768
TrAX Templates, 731
XSLTemplate
MSXML3, 777
createProcessor(), 731
DOCTYPE
, 88
XML
XML, 307
, 81
, 72
,
xsl:attribute, 192
, 79
, 80
, 955
, 81
, , 955
XSLT, 338
, 157
localname(), 81
name(), 80
namespaceuri(), 81
XML, 307
HTML, 314
XML, 309, 311
XML
encoding, 307
standalone, 307
version, 307
, 97
generateid(), 695
xsl:applytemplates, 694
987
, 414
+, 392
, 25
,
, 577
(DTD)
, 955
, 50
, 109
988
, 173
, 421, 423
, 394
XPath, 493
( mod), 428
XML, 779
HTML, <xml>, 779
, 244
, 156
URI
URI
, 79
, 437
//, 450
, 106
, 106, 459
HTML, 313
XML, 309
, 210
XML Oracle
(XDK), 809
, 666
, 100
, 316
, 316
HTTP, 318
, 317
xsl:applytemplates,
182
xsl:calltemplate,
205
, , 393
, 956
, 507
, 705
priority, 706
, 99
, 484
, 222
,
247
, 374
, 351
, 675
, 667
, 372
,
135
xsl:import, 264
xsl:fallback, 245
, 109
, 403
,
, 570
, 106
, 399
, 395, 668
,
665
,
, 505
, 484
, 486
, 957
, 380
, 173
, 103
, 106
, 106
XPath, 386
,
xsl:number, 290
, 399
and, 400
or, 402
, 110
xsl:applytemplates, 180
xsl:foreach, 250
, 172
, 958
, 334
, 334
,
MSXML3, 781
,
664
Xalan
URL, 885
, 885
HTML, 885
SAX2
ContentHandler, 885
, 884
, 50
,
, 700
xsl:applytemplates, 702
, 632
, 99
, 618
, 70
, 475
, 461
,
103
, 102
, 958
, 581
xsl:if, 254
, 584
,
xsl:foreach, 251
, , 958
, 119
xsl:decimalformat, 260
xsl:key, 260
xsl:namespacealias, 260
xsl:output, 260
xsl:param, 261
xsl:preservespace, 261
xsl:stripspace, 261
xsl:template, 261
xsl:variable, 261
, 260
xsl:decimalformat, 228
xsl:namespacealias, 286
xsl:output, 305
xsl:preservespace
xsl:stripspace, 323
,
352
989
xsl:applyimports,
177
xsl:applytemplates,
181
, 258
, 958
xsl:key, 274
xsl:import, 256
, 259
/
, 260
xsl:import, 259
xsl:include, 259
xsl:include, 268
, 281
XML, 74
name(),
568
, 958
990
XSLT
,
, 146
, 74, 441
, 192
, 240
, 958
, 495
Java, 625
Java, 626
,
633
NodeList Node, 634
, 634
null, 633
, 633
, 633
,
633
Java, 625
, 630
XPath,
, 633
,
629
, 625
, 91
,
xsl:template, 355
Hello World, 29
xsl:variable, 379
xsl:comment, 217
, 685, 709
XML, 710
INDI, 710
XML,
710
, 712
HTML, 722
xsl:import,
,
722
, 713
HTML
XML, 713, 714
, 714
HTML, 721
, 716
, 718
,
, 718
GEDCOM,
HTML, 713
GEDCOM XML, 732
GEDCOM, 732
HTML ASP
, 728
HTML ,
729
createProcessor(),
731
init(), 731
refresh(), 731
transform(), 731
,
.
XML
, 96
, 141
date:new(), 145
xsl:applytemplates,
186
, 116
xsl:calltemplate, 118
xsl:template, 118
xsl:copy, 117
xsl:copyof, 117
xsl:script, 117
xsl:number, 300
,
164
xsl:fallback, 245
xsl:fallback, 246
xsl:copyof, 223
, 157
, 585
, 671
, 673
, 685
, 736
,
749
, 738
xsl:calltemplate xsl,
739
, 743
makes moves, 743
xsl:otherwise, 745
,
741
,
738
,
740
,
738
start
translate(), 740
XSLT, 735
, 749
, 737
, 737
, 735
991
xsl:template, 358
xsl:sort, 335
xsl:import, 264
HTML
xsl:attributeset, 203
XML, 685, 686
XSLT XPath, 708
,
, 686
,
xsl:decimalformat
, 707
<!DOCTYPE>, 688
XML, 688
, 693
, 694
xsl:appytemplates,
694
XML, 687
,
696
, 696
, 696
HT
ML, 688
, 688
xsl:applytemplate,
689
,
705
, 706
, 705
, 708
, 708
, 700
xsl:applytemplates, 703
<scrap>, 700
, 707
, 690
, 691
992
XML
, 697
, 699
, 697
xsl:if, 255
, 51
, 93
, 94
xsl:applytemplates, 94
xsl:number, 94
xsl:template, 356
xsl:preservespace xsl:stripspace,
322
,
, 99
xsl:apply
templates, 181
,
, 353, 476
, 387, 397
, 959
, 99
, 353
.
xsl:preservespace, , 320
xsl:stripspace, , 165, 336
, 424
, 324
, 91, 135, 166
, 360
xsl:text,
361
,
concat(), 361
, 162
XPath, 447, 468
,
109
xsl:applytemplates, 179
, 162, 959
, 361
xsl:text, 166
normalizespace(), 362, 575
, 163
, , 580
, , 574
, , 580
, 387
,
, 621
, 496
, 188
, 671
, 189
, 675
API XML
. API SAX
XML, , 39
XSLT, 123
XML, 308
,
257
, 342
, 269
, 39
, 341
URI
, 40
, 40
URI, 39
, 342, 349
DTD, 40
,
514
, 40
, 574
DTD
, 40
, 959
, 79, 338
XPath, 80, 422, 442
, 80
,
, 40
, 39
, 39
, 344
,
XML, 25
, 90
, 64
XSLT, , 63
, 63
Instant Saxon
, 31
XalanJava
, 31
, 110
, , 612
, 110
, 105
, 109
XML Query, 56
,
last() position(), 561
CDATA
, 88
, 103
, 444, 462
, 959
, 403
, 93, 99, 476
, 99
, 99
993
, 152
, 245
, , 527
, 74, 80
, 959
format
xsl:number, 152
lang
xsl:number, 152
xsl:sort, 152
method
xsl:output, 152
,
, 152
,
, 152
XSLT,
, 152
, 152
, 152
, 151
, 152
system property(), 152
,
, 152
VBScript
MSXML3, 754
, 109
, , 612
xsl:applytemplates, 181
, 182
, 380
, 97
, 186
,
514
, 960
, 358
994
, 137, 160, 340, 528, 536
,
132
xsl:document,
233
systemproperty(), 161
xsl:include, 271
xsl:applytemplates, 186
,
670
, 585
, 208
, 207
, 210
, 675
xsl:calltemplate, 207
, 76
(..), 453
, 70, 960
URI , 80
, 80
, 80
async
MSXML3, 771
preserveWhitespace
MSXML3 DOM, 757
, 960
CDATA
XML, 310
, 960
, 318
, 66, 233
XML, 88
, 88
DOCTYPE, 88
, 67
CDATA, 88
standalone, 88
, 67
, 88
xsl:output, 303
, 83
<, , 362
, 265
, 168
, 75
, 109
stringlength(), 594
,
, 258
SAX
GEDCOM
XML, 733
SAX2 GEDCOM, 733
(XPath), 388
, 610
, , 535
, 391
, 324
,
167
, 576
(), 295
functionavailable(), 160
xsl:fallback, 160
xsl:stylesheet, 159
, , 500
, , 540
,
xsl:choose, 214
EDI, 65
,
document(), 518
, 330
, 333
Saxon, 842
xsl:apply
templates xsl, 107
, 148
xsl:foreach, 250
xsl:apply
templates, 180
saxon:function
, 854
, 133
, xsl:sort, 332
, , 499
XML
, 686
, 687
xsl:output, 688
xsl:param, 688
xsl:stylesheet, 688
c XPath
, 400
XSLT 1.1
DOM
XPath, 622
, ,
, 600
xsl:calltemplate, 205
, 355
, 960
XML, 309, 310
, 326
, 163
, 960
XML, 84
HTML, 312
XML, 163
, 960
XML, 84
995
, 394
xsl:applyimports, 265
xsl:import, 265
HTML
, 722
xsl:import, 722
, 102, 398
, 405
, 590
, 600
, 100, 109
, 961
(), 75
, 367
, 83
, 960
, 110
XPath
Java, 631
, 114
,
115
<?xmlstylesheet?>, 114
, 114
, 115
, ,
115
, 115
, 115
, 114
, 115
xsl:stylesheet, 114
xsl:transform, 114
, 114
, 663
xsl:import, 174
xsl:include, 174
xsl:stylesheet, 174
, 585
, 108
996
, 70
, 614
, 961
stringlength(), 594
UML , 77
, HTML
, 216
, 678
, 675
, 629
.
, , 519
CSS, 327
xsl:attribute
set, 198
MSXML3
, 753
(xsl:docu
ment), 753
xsl:script
,
754
,
754
VBScript, 754
XSLT 1.0, 753
systemproperty()
, 756
XSLT
XPath
,
397
MSXML3, 781
XSLT
,
, 781
Saxon
, 31
, 49
, 471
XML, 48
, 33
, 51
, 53
, ,
51
, 126
, 657
, 652
,
749
, 738
translate(), 738
, 743
xsl:otherwise, 745
, 735
, 736
, 737
XSLT, 735
,
740
format number()
, 741
xsl:choose, 742
, 284
, 173
, 961
, 658
, 707
xsl:template, 707
997
, , 708
priority, 708
, 515
xsl:namespacealias, 287
, 64
, 132
XML, 685
HTML,
714
key(), 715
renderDocument(), 728
,
, 239
, 363
, 697, 699
border, 699
, 72
URI, 75
, 129, 135
, 98
, 73
, 163
, 961
, 75
, 961
, 175
xsl:calltemplate, 205
, 961
xsl:applyimports
, 175
, 103, 560, 583
, 962
, 103, 506, 583
xsl:applytemplates, 180
xsl:calltemplate, 205
xsl:foreach, 249
, 962
, 355
, 92
XSLT, 135
, 173
, 91, 962
, 135
, 92
, 135
, 135
, 135
, 64
MIME
HTML, 314
XML, 311
, 314
, 82
HTML, 314
XML, 311
, 314
, 512
XSLT/XPath, 99, 104
, 100, 395
, 111
, 112
IEEE 754
, 106
, 100, 105
, 100, 110
, 110
, 100, 109
, 110
, 100
, 100, 106
, 106
, 107
, 414
XPath, 105
, 163
, 72
URI, 75
,
98
998
, 74
, 81
, 962
, 76
, 75
, 71
, 101
, 101
, 101
, 101
, 190
, 215
, 72
URI, 75
,
98
, 74
, 963
, 75
, 72
URI, 75
,
98
, 73
, 963
, 75
, 103
, 71
, 962
xsl:foreach, 251
, 76
xsl:calltemplate, 206
, 72
URI, 75
,
98
, 74
xsl:foreach, 98
, 963
, 285
, 77
, 76
, 75
, 144
, 72
, 72
, 76
URI, 75
,
98
, 74
, 963
, 76
, 77
, 75
, 428
,
107, 108
, , 505
, 466
, 109
, 132
, 134
, 963
,
270
, 669
. XPath:
GEDCOM
XML, 732
SAX, 733
, 734
, 148
xsl:namespacealias, 285
, 258, 270
, 342
xsl:element, 241
SAX2
Saxon, 840
, 24
XSL
Saxon, 829
, 185, 251,
358
xsl:applytemplates, 93
, 111
XSLT 1.1, 225
, 963
, 105,
537
,
, 105
, 493
after(), Saxon, 843
baseuri(), Saxon, 843
before(), Saxon, 843
boolean(), 104, 108, 495
. true()
false()
, 495
, 495
, 496
ceil(), 108
ceiling(), 497
, 497
, 498
concat(), 149, 210, 498, 600
, 395
,
149
, 212
, 361,
365
, 499
, 671
, 500
, , 499
contains(), 501
, 501
, 502
count(), 166, 502, 671
xsl:number,
296
, 404
, 414
last(), 504
xsl:number,
504
999
count()
,
, 503
,
505
, 503
, 503
, 504
, 512
,
, 166
createProcessor(), XSLTem
plate, 731
current(), 103, 505, 519
, 506
, 484
, , 507
, , 507
, 506
, 507
difference()
Saxon, 843
Xalan, 880
distinct()
, 536
Saxon, 843
Xalan, 880
document(), 68, 76, 103, 131, 180,
235, 253, 509, 511, 513, 624
, ,
515
, 390
, 318
, 510
,
517
, 515
, 517
, 513
, 513
, 517
, 521
, 131
,
321
1000
document()
ID
,
521
URI, 76, 103
, 68
,
, 514
, 518
, 519
xsl:foreach, 253
elementavailable(), 158, 161, 522
, 522
,
XSLT, 523
, 526
, 528
, 526
, 527
, 158
, , 523
endswith(), , 590
entityuri(), 77
eval(), Saxon, 844
evaluate()
Saxon, 844
, 849
Xalan, 880
exists(), Saxon, 844
expression(), Saxon, 845
false(), 105, 529
, 529
, 529
floor(), 108, 529
, 530
, 530
forall(), Saxon, 845
formatnumber(), 108, 291, 441, 531
xsl:decimal
format, 226
decimalformat, 531
, 108
, 534
, 534, 674
formatnumber()
xsl:number, 289
, 532
, 532
functionavailable(), 156, 158, 160,
161, 396, 535
, 156
,
537
, 536
, 535
, 536
, 537
, 160
generateid(), 508, 539, 682, 695
,
682
, , 552
, 695
, , 543
, 539
, 540
, 512
, , 540
getuserdata(), Saxon,
845
hassamenodes(),
Saxon, 845
hasSameNodes(),
Xalan, 881
highest(), Saxon, 845
id(), 82, 90, 545, 715
key(), ,
, 547
, 488
,
521
,
546
, 545
, 547
if(), Saxon, 846
init(), 731
HTML,
, 731
intersection()
Saxon, 846
Xalan, 881
isnull(), Saxon, 846
key(), 104, 252, 441, 548, 682, 715
, 484, 488
,
521
, 552
, 104
id(), 547
, 550
,
, 553, 682
, 549
xsl:foreach, 252
xsl:key, 272
, 548
, 549
,
550
HTML
, 715
lang(), 555
, 555
, 556
, 558
, 557
last(), 103, 180, 504, 559
, 475, 485
xsl:foreach, 249
xsl:applytemplates, 180
xsl:sort, 562
, 444,
462, 562
count(), 504
, , 561
, 560
, 560
, 561
, 562
1001
1002
normalizespace()
xsl:stripspace, 576
, 168
not(), 105, 578
, 579
, 579
!=, 413
, 579
, 580
, 580
, 580
!=, 579
number(), 104, 580
, 582
, 581
, 108
, 581
, 580
, 581
, 582, 671
path(), Saxon, 847
position(), 103, 166, 180, 444, 582
xsl:number, 296,
584
, 583
, 475, 485
xsl:foreach, 249
xsl:applytemplates, 180
xsl:sort, 334
, 324
, 444
, 143
,
584
,
584
, 583
, 584
position()
, 585
, 584
,
, 166
,
, 583
, 584
range(), Saxon, 848
refresh(), 731
HTML,
, 731
renderDocument()
, 728
round(), 108, 586
, 587
, 588
, 588
setuserdata(), Saxon,
848
startswith(), 589
, 590
, 590
string(), 104, 108, 226, 591
, 591
, 592
,
, 591
stringlength(), 83, 110, 593
, 594
, 594, 596
, 594
, 594
substring(), 83, 148, 595
, 597
, 595
, 597
, 597
, 148
substringafter(), 211, 499, 599
, 599
, 600
, 671
substringafter()
, ,
, 600
, , 600
substringbefore(), 211, 499, 601
, 602
, 212
, 601
, 601
, 671
sum(), 108, 604, 671
,
673
, ,
606
, 605
systemid(), Saxon, 848
systemproperty(), 152, 161, 247,
608, 610
, 395
, , 610
, 609
, 609
, 161
,
609
tokenize()
Saxon, 848
Xalan, 881
transform(), 731
translate(), 210, 295, 602, 611, 738,
740
, 109
, 602
,
612
, 612
, 612
, 612
, , 738
1003
1004
Saxon
leading(), 846
linenumber(), 846
lowest(), 847
max(), 847
min(), 847
nodeset (), 847
path(), 847
range(), 848
setuserdata(), 848
systemid(), 848
tokenize(), 848
URI , 620
Xalan
difference(), 880
distinct(), 880
evaluate(), 880
hasSameNodes(), 881
intersection(), 881
nodeset(), 881
tokenize(), 881
xsl:script, 328, 620
, 620
, 637
, 633
, 633
XPath, 619
,
619
, 394
, 619
XSLT, ,
621
, 668
, 153
,
153
DOM, 623
DOM, 623
, 153
, 964
Java, 625
, 395
, 618
DOM, 623
XPath, 623
, 154
, 620
, 617
,
156
, 670
, , 640
, 394
,
663
XSLT , 664
, 667
, 666
Saxon, 842
, 212
, 670
document(), 512
, 108
, 108
, 108
,
xsl:if, 255
, , 606
, , 100, 106
, 106
, 964
, 333
XPath
Java, 630
, 108
, 665
, 172
, 964
xsl:attribute, 193
, 90
, 98, 181
, 181
, 173
, 964
, 99
xsl:template, 350
, 151
, 149
, 148
substring(), 148
xsl:attribute, 148
xsl:calltemplate
, 150
HTML
<object>, 778
formatnumber(), , 533
XPath, 465
, 106
, 21
meta
HTML, 313
msxsl:script, 155
saxon:assign, 668
saxon:group, 684
script
HTML, 66, 312
1005
style
HTML, 312
xalan:component, 874
, 874
, 875
xalan:script
, 875
Java, 876
JavaScript, 877
JavaScript
Xalan, 878
:
, 879
xsl:applyimports, 136, 174, 265,
506, 528
. xsl:import
, 175
, 176
, 177
, 265
xsl:applytemplates, 53, 92, 93, 94,
97, 98, 103, 107, 136, 151, 166,
175, 176, 178, 184, 194, 206, 457,
504, 506, 514, 538, 560, 563, 583,
585, 689, 694, 702, 703, 718
HTML,
, 689
, 184
xsl:call
templates, 206
mode, 181
, 178
, 103
, 98, 181
, 181
,
206
, 718
, 53
, 185
,
, 659
1006
xsl:applytemplates
, 97
, 194
, 107
,
671
, 694
, 92
, 182
, 702
,
, 181
, 98
, 186
, 189
, , 181
, 181, 186
, 186
,
, 166
HTML, 689
xsl:foreach,
185, 251
, 180
, 703
last(), 180
position(), 180
,
151
xsl:attribute, 136, 148, 149, 184, 190
namespace, 192
, 194
HTML, 195
, 195
xsl:element, 238
, 193
, 192
, 193
xsl:attribute
, 143
xsl:attributeset, 191
, 192
, 196
, 195
xsl:copy, 194
, 193
,
148, 149
xsl:attributeset, 122, 130, 143, 191,
194, 198
xsl:attribute
, 191
useattributesets, 201
, 198
, 260
, 199
, 201
,
143
, 201
HTML, 203
xsl:include, 271
CSS
, 198
xsl:breakpoint, 528
xsl:calltemplate, 97, 118, 136, 150,
175, 176, 189, 204, 205, 206, 506,
562, 689, 739
HTML,
, 689
, 205
xsl:apply
templates, 206
name
, 150
xsl:calltemplate
, 204
, 204
, 205
xsl:variable, 205
, 204
, 206
, 97
, 205
, 208
, 207
,
, 210
, 210
, 205
, 118
, 206
,
, 210
, 207
,
, 208
xsl:choose, 136, 197, 213, 598
, 213
, 214
, 214
xsl:if, 254
formatnumber()
, 742
xsl:comment, 91, 136, 184, 215
Java
Script, 217
, 216
,
217
1007
, 194
, 235
, 112
, 221
, 223
xsl:valueof, 222
, 117
, 223
xsl:copy, 220
xsl:decimalformat, 130, 226, 531
, 227
, 260
, 228
formatnumber(), 532
, 229
, 228
, 229
1008
xsl:fallback
,
245
, 158
, 245
, 246
, 160
, 247
, 159
xsl:foreach, 97, 103, 107, 136, 151,
175, 185, 189, 206, 248, 398, 457,
504, 506, 508, 547, 551, 559, 560,
583, 703
, 251
select, 249
, 249
, 103
, 249
xsl:template, 206
, 97
, 107
,
98
, 251
, 671
, 251
, 522, 547
,
251
, 252
xsl:apply
templates, 185, 251
, 250
, 703
document(), 253
key()
, 252
,
151
1009
,
271
xsl:import, 263
xsl:key, 104, 130, 272, 484, 499, 548,
560, 583, 682
match, 471
, 273
, 260
, 273
key(), 548
, 275
,
682
, 277
, 278
, 279
, 280
, 273
normalizespace(),
576
xsl:message, 91, 281, 740
terminate, 281
, 281
MSXML3, 757
, 281
, 283
, 91
, 282
xsl:namespacealias, 130, 147, 284,
285
, 284
, 260
, 285
, 286
, 287
xsl:number, 94, 136, 149, 152, 288,
504, 584, 702
level = any, 298
level = multiple, 301
level = single, 296
count, 471
format
, 152
1010
xsl:number
from, 471
lang, 295
, 152
lettervalue, 295
, 295
,
702
, 290
formatnumber(), 534
, 296
, 290
, 300
, 292
,
, 166
count(), 296
formatnumber(), 229
position(), 296, 584
, 289
, 293
count()
, 504
,
149
xsl:otherwise, 302, 745
. xsl:choose
, 303
, ,
745
xsl:output, 66, 117, 130, 149, 150,
151, 152, 167, 303, 688
method,
, 152
, 309, 314
HTML, 313
, 260
, 150
xsl:output
HTML, 66
, 311
XML, 66
, 305
, 66
, 314
, 315
, 305
, 66
XML,
308
, 67
HTML,
688
, 305
, 316
XML
, 688
,
167
,
149, 151
xsl:param, 102, 130, 135, 183, 205,
316, 414, 456, 512, 688
, 317
, 261
, 317
, 100
, 317
, 318
, 318
, 319
xsl:variable, 318
XML
, 688
, 135
xsl:template, 205
xsl:preservespace, 130, 162, 320,
421, 441, 510
, 321
, 321
document(), 510
, 261
, 323
, , 322
, 324
1011
1012
xsl:transform, 337
,
, 131
, 158
xsl:template, 53, 91, 99, 100, 118,
120, 130, 134, 135, 147, 148, 173,
177, 189, 205, 349, 484, 514, 560,
707
, 350
match, 90, 114, 351, 471
mode, 354
name, , 352
priority
, 352
, 99
, 261
, 147
, 350
, 359
, 189
, 205
, 355
, 358
, 356
, 118
, 91
xsl:comment, 216
, 707
, 135
,
134
xsl:param, 205
xsl:withparam, 205
, 120
xsl:text, 84, 91, 136, 164, 168, 360,
693
, 360
,
168
xsl:text
, 360
,
, 693
, 362
, 164, 166, 168, 361
, 365
xsl:transform, 114, 119, 123, 129,
337, 366
disableoutputescaping, 369
, 114
xsl:stylesheet, 337,
366
, 129
xsl:useattributeset, 143
,
143
xsl:valueof, 35, 37, 53, 84, 97, 131,
136, 140, 159, 179, 185, 366, 499,
716
xsl:fallback
, 159
HTML
, 35
, 53
, 155
, 367
, 368
, 97
, 673
xsl:copyof,
222
,
179
, 370
SELECT SQL, 185
, 140
1013
, 244
, 119
, 129, 965
XSL, 129
XSLT, 130
,
129, 130
,
129, 130
extensionelement
prefixes
, 130
,
, 130
, 339
xsl:attribute, 174
xsl:comment, 174
xsl:element, 174
xsl:processinginstruction, 174
xsl:text, 174
xsl:valueof, 174
, 70
, 965
xsl:copy, 174
xsl:copyof, 174
xsl:number, 174
xsl:choose, 174
xsl:foreach, 174
xsl:if, 174
xsl:otherwise, 174
xsl:when, 174
, 964
xsl:param, 174
xsl:variable, 174
xsl:withparam, 174
xsl:excluderesult
prefixes, 158
, 137
, 348
xsl:fallback, 137
1014
, 158
, 965
Saxon, 839
, 522
, 243
, 341
, 157
saxon:while, 157
xsl:fallback, 158, 159
xsl:stylesheet, 158
extensionele
mentprefixes, 156
saxon:group,
137
Saxon
saxon:assign, 851
saxon:doctype, 852
saxon:entityref, 852
saxon:function, 853
, 854
saxon:group, 137, 853
saxon:item, 853
saxon:preview, 853
saxon:return, 853
saxon:while, 157, 854
xsl:sort, 174
xsl:document, 174
xsl:output, 174
xsl:applytemplates, 174
xsl:template, 174
(XSLT), , 172
, 224
, 681
, 275
, 374, 375
, 209,
210
, 666
CSS
CSS2, 41
, 41
, 41
XSLT XSLFO
, 42
, 43
CSS ,
3
576 .,
, ?
,
CSS2 CSS2.1.
CSS ,
, , , ,
,
.
, ,
, ,
,
, CSS3,
IE7, Firefox , ,
.
CSS
.
. CSS
, .
HTML 4.0.
XSLT, 2-
960 .,
XSLT,
.
XSLT1.0 XSLT 2.0. XSLT,
.
,
XPath1.0 2.0. , XSLT2.0
XML Schema,
,
, ,
, XSLT XPath, ,
XSLT1.0 2.0, ,
.
1995
.
,
.
: OReilly, Pearson Education, NewRiders,
Addison Wesley, Wiley, McGrawHill, No Starch Press, Packt, Dorset
House, Apress .
, , .
:
:
. . 16 , . 7 (. ),
. (812) 324-5353
:
. , . 13 (. ),
. (495) 9458100
http://www.symbol.ru
.
www.symbo l . r u
,
.
, , www.symbol.ru.
. !