XML. Meta-Language, XML. XML SGML XML, -, -.,, XML DTD ( ). DTD, DTD. XSLT(Extensible Stylesheet Language Transformation). (Specify).. XSLT XML W3C.,. SGML Tool. XSLT. XML.
16, XSLT,. XSLT XML. XSLT XSLT,. XSLT XSLT, (Task Oriented). XSLT., XSLT.
XSLT. XSLT (Reference) XSLT 20%. 20% 80%., (Users Guide). Part. Part 1 XSLT XSLT (Tutorial). Part 2. Part 2 XSLT (users guide). XSLT (,,, document () ) (,, ). ( XSLT ). Part 1 Part 2..,.
18 XSLT (type),,., document () Part 2. XML, XML -,, well-formedness,. XSLT XML (, CDATA,, ) Part 2, 4 XML. HTML XML., XSLT XML HTML, HTML ( p, img, i, h 1 h2 h3, a ). (zip ). ht tp :/ / www.manning.com/ duch arme ht t p :/ / www.snee.com/ XSLTQuickly. /. zip. <!- - xql 023.x s l : c onv e rt s xq1022.xml i nt o xq1024.xml - - >
19 zip, xq1023.xsl, xq1022.xml, xq1024.xml. xsl:stylesheet, (xsl :template ). zip. processing instruction. <!- - xq1023.xsl : conver t s xq1022.xml i nt o xq1024.xml - -> <xsl :t empl at e mat ch="wi ne"> <xsl :val ue- of sel ect ="pr i ce" / > </ xsl :t empl at e> xq1023.xsl. <xsl : st yl esheet xml ns :xsl =" ht tp:/ / www.w3.org/ 1999/ XSL/ Transform" ver si on=" 1. 0"> <xsl :out put met hod="xml " omi t -xml - decl ar at i on=" yes" i ndent ="no" / > <? st ar t Sampl efi l e?> <!- - xq1023.xsl : conver t s xq1022.xml i nt o xq1024.xml - -> <xsl :t empl at e mat ch="wi ne"> <xsl :val ue- of sel ect ="pr i ce" / > </ xsl :t empl at e> <?endsampl efi l e?> </ xsl :st yl esheet >.. ( XML ). Organization for the Advancement of Structured Information (OASIS) DTD DocBook. XML (SGML DTD ). XML DocBook
20., HTML PDF.., DTD,, DocBook DTD. DocBook,. <!DOCTYPE chapt er PUBLIC " - / / OASI S/ / DTD DocBook XML V4. 0bet a1/ / EN" " docbook.dt d"> <chapt e r><t i t l e>my Chapt er</ t i t l e> <par a>thi s paragraph int roduces the chapter ' s sections.</ par a> <s e c t 1><t i t l e>sect i on 1 of "My Chapt er "</ t i t l e> <par a>here i s t he fi r st sect i on ' s fi r st par agraph.</ par a> <par a>her e i s t he f i r st sect i on ' s second par agr aph.</ para> </ s e ct 1> <s e c t 1><t i t l e>sect i on 2 of "My Chapt er "</ t i t l e> <par a>here i s t he fi r st sect i on ' s fi r st par agraph.</ par a> <s ec t 2><t i t l e>sect i on 2.2</ t i t l e> <par a>thi s sect i on has a subsect i on.</ par a> </ s e c t 2> </ sect 1> </ chapt e r> (DocBook DTD, http :/ / www.docbook.org ), J ohn Milton Paradise Lost., (spelling).
21 AUTHOR ONLINE Manning.,. http :/ / www.manning.com/ ducharme.,,. Manning.. AO(Author Online. ),.. AO Archive. Manning,..
, Soldado J apon de Cavalleria,.,. 1799,.. R.M.V.A.R.. (by hand),,,. Soldado J apon de Cavalleria. 200,.,.,.,?, Manning.
P A R T 1 XS LT.,,,,,., XSLT,.,. XML DTD XML XML XML (supplier) XML,,.,.
C H A P T E R 1 XS LT 1.1 XSL, XPATH, XSLT? 1.2 XSLT 1.3 1.4 1.1 XSL, XPATH, XSLT? XSLT(Extensible Stylesheet Language Transformation) XML XML HTML. XML XSLT. XML (element) (attribute). World Wide Web Consortium(W3C), XML HTML. XSLT? XML,. DTD..,. XSLT. W3C XML..
26 PART 1 XSLT 1.1 XSLT. XSLT XSL(Extensible Stylesheet Language). XSL. XSL (Specification) XSL. XML, XML. (formatting-object ),, (margin),,. (formatting-language). XSL,. W3C XSL Working Group,., XML. XSLT,. XSL XSLT. XSLT. XSLT XPath
CHAPTER 1 XSLT 27 ( XML Tree ) (path). XPath chapter (ancestor) revisiondate. W3C XPath, W3C ([ 1.2] )., XLink XPointer XPath. 1.2 W3C 1998 8 XSL Wor k in g Dr a ft, 1999 4 XSLT Wor k in g Dr a ft. 1999 6 XPa t h Wor k in g Dr a ft. 1.1.1 XSLT XSLT XML,. XML. J ava, Perl, Visual Basic, Python, C+ +. XML( SGML). Omnimark Balise. XSLT? XSLT. XSLT. XSLT (Vendor).,. XSLT.,
28 PART 1 XSLT,. XSLT., XSLT., W3C XSLT W3C, W3C XSLT. (Standard-Driven) XML., XML..,., URI (prefix), XML (parser). XML XSLT XSLT XML. XML., XML (synt ax) XSLT,. 1.1.2,,, XSLT. XSLT,.? XSLT XSLT. XML. XSLT. XSLT / /. XSLT,
CHAPTER 1 XSLT 29 DOM(Document Object Model), XSLT DOM (DOM W3C, XML )., XSLT? XSLT., XSLT /,.,., DOM, XSLT,. [ 1.3] XSLT (poem) HTML. 1.3, XSLT, XSLT,, XML DOM., XSLT..,. SAX(Simple API for XML) (Event-Driven),.,,
30 PART 1 XSLT,,. XSLT, /...,, Processing Instructions,, (, ). <?xml - St yl esheet hr ef=" ar t i cl e.xsl " t ype=" t ext / xsl "?> <ar t i cl e> <!- - her e i s a comment - -> <t i t l e aut hor ="bd">sampl e Document </ t i t l e> <par a>my 1st par agr aph.</ par a> <par a>my 2nd par agr aph.</ par a> </ ar t i cl e>. 1.4.. Title, para.,... para,
CHAPTER 1 XSLT 31,. <par a>my 1st par agr aph.</ par a><par a>my 2nd par agr aph</ par a>, article,. XSLT (XSLT ),..., ( article )., Processing Instruction article article. Processing Instruction article. Processing Instruction article (article) (Processing Instruction). 1.2 XSLT XSLT well-formed XML, XSLT. XSLT. XSLT xsl ( XSL formatting object fo ). XSLT xsl. xsl:text xsl :message, XSLT text message. XSLT xsl.,, XSLT harpo:text, harpo:message.
32 PART 1 XSLT xml ns :harpo=" ht tp:/ / www.w3c.org/ 1999/ XSL/ Tr ansform" XSLT, xsl:stylesheet well-formed XML (, ). <!- - xq15.xsl : conver t s xq16.xml i nt o xq17.xml - -> <x s l :s t yl e s he e t xml ns :x s l ="ht t p :/ / www.w3. or g/ 1 999/ XSL/ Tr ans f orm" v e r s i on="1. 0"> <x s l :t empl at e mat ch="ye ar"> <vi nt age> <xsl :appl y- t empl at es/ > </ vi nt age> </ xs l :t empl at e> <x s l :t empl at e mat ch="pr i c e"> </ xs l :t empl at e> <!- - Copy al l t he ot her el ement s and at t r i but es, and t ext nodes - -> <x s l :t empl at e mat ch="* @* t ext ()"> <xsl :copy> <xsl :appl y- t empl at es sel ect ="* @* t ext ()" / > </ xsl :copy> </ xs l :t empl at e> </ xs l :s t yl e she et > 1.2.1 XSLT (template rule). (pattern) (template), XSLT,, (template)., xsl :template.,. xsl :template match,. -,,., xsl:template
CHAPTER 1 XSLT 33 XSLT match ( ), ( ).. XSLT year 1.5 ( year child : :year )., vint age. xsl:apply-template, ( (relevant ). 1 )., year vint age tag., year vintage. [ 1.5]. XSLT (instruc -tion). XSLT. vintage xsl? well-formed XML, vintage. XSLT, XSLT. XSLT literal result element ( )., xsl:template XSLT (, ( ) match ). price.?., (empty). XSLT price,
34 PART 1 XSLT., price. XML, ( single-tag empty element ). <xsl :t empl at e mat ch="pr i ce" / > XSLT.., ( (element type), )., XPath (match pattern) ( )..,, xsl :copy xsl:apply-templates node (,, ).. XSLT. year price, (, year. year ).,., XSLT. xsl:template, XSLT. xsl:template match., (aixs) XPath (XPath, 2, XPath ). year price, * @* text ().
CHAPTER 1 XSLT 35. price, year vint age., wine element <wi ne gr ape=" char donnay"> <pr oduct >Car ner os</ pr oduct > <year>1997</ year> <pr i ce>10. 99</ pr i ce> </ wi ne>. <?xml ver si on=" 1. 0" encodi ng="ut f - 8"?> <wi ne gr ape=" char donnay"> <pr oduct >Car ner os</ pr oduct > <vi nt age>1997</ vi nt age> </ wi ne> price. price, (Carriage Return)., XML.. XSLT. 1.2.2 XSLT C B A? XSLT. XSLT. / (Dialog Box), (Command Line).
36 PART 1 XSLT XSLT /., (Programming Library)., XSLT.,. /, XML. XSLT., /.,.. /. Xalan ( ( Zalan) ). XSLT IBM Apache XML (http :/ / xml.apache. org). winsale.xsl winelist.xml, winesale.xml, Xalan (2.0 ) ( ). j ava or g.apache.xal an.xsl t.pr ocess - i n wi nel i st.xml - xsl wi nesal e.xsl - out wi nesal e.xml (, path ) XSLT, A XSLT.
CHAPTER 1 XSLT 37 1.6 XSLT XML XSLT. 1.2.3 XSLT?, (empty)? <!- - xq21.xsl : conver t s xq22.xml i nt o xq23.xml - -> <xsl : st yl esheet xml ns :xsl =" ht tp:/ / www.w3.org/ 1999/ XSL/ Transform" ver si on=" 1. 0" / > XSLT (built-in), XSLT, (XML PCDATA)., <wi nel i st dat e=" 20010626"> <wi ne gr ape=" char donnay"> <pr oduct >Carne r os</ pr oduct > <year>1 997</ year> <pr i ce>10. 99</ pr i ce> </ wi ne> </ wi nel i st >.
38 PART 1 XSLT <?xml ver si on=" 1. 0" encodi ng="utf- 8"?> Car ner os 1997 10. 99 XSLT XML. HTML (plain text) XML, xsl:output (overridden)., XSLT (, XSLT wine-list, wine ( XML )).,,., XSLT ( ). (grandchild). 1.3 xsl :apply-template. XSLT ( (matched) xsl :template match ). select,.. <!- - xq25.xsl : conver t s xq26.xml i nt o xq27.xml - -> <xsl :t empl at e mat ch="wi ne"> <wi ne> <pr i ce><xsl :appl y- t empl at es s e l e c t ="pr i ce"/ ></ pr i ce> <pr oduct ><xsl :appl y- t empl at es s e l ec t ="produc t "/ ></ pr oduct > </ wi ne> </ xsl :t empl at e>
CHAPTER 1 XSLT 39 XML <wi ne gr ape=" char donnay"> <pr oduct >Car ner os</ pr oduct > <year>1997</ year> <pr i ce>10. 99</ pr i ce> </ wi ne>. <wi ne> <pr i ce>10. 99</ pr i ce> <pr oduct >Car ner os</ pr oduct > </ wi ne>. price product ( ). year. xsl :applytemplates., ( ). xsl:apply-templates. 1.3.1.?, wine price, year vintage, (XML. )?
40 PART 1 XSLT <wi ne pr i ce=" 10. 99" year =" 1997">Car ner os</ wi ne>. <wi ne vi nt age=" 1997">Car ner os</ wi ne>. <!- - xq30.xsl : conver t s xq28.xml i nt o xq29.xml - -> <xsl :st yl esheet xml ns :xsl ="ht tp:/ / www.w3. org/ 1999/ XSL/ Transform" ver si on=" 1. 0"> <xsl :t empl at e mat ch="wi ne"> <wi ne vi nt age="{ @year} "> <!- - pri c e at t ri but e - - > <xsl :appl y- t empl at es/ > </ wi ne> </ xsl :t empl at e> <!- -. - -> <xsl :t empl at e mat ch=" @* node ()"> <xsl :copy> <xsl :appl y- t empl at es sel ect =" @* node ()" / > </ xsl :copy> </ xsl :t empl at e> </ xsl : > price. price. year vintage vintage = {@year}. wine year. @ XPath. ({) XSLT (attribute value template).. vintage = {2 + 2}, XSLT vintage = 4. XSLT @,.
CHAPTER 1 XSLT 41 1.3.2.,, @.. grape wine product., year vintage. <wi ne gr ape=" Char donnay"> <pr oduct >Car ner os</ pr oduct > <year>1997</ year> <pr i ce>10. 99</ pr i ce> </ wi ne>. <wi ne vi nt age=" 1997"> <pr oduct >Car ner os</ pr oduct > <cat egor y>char donnay</ cat egor y> <pr i ce>10. 99</ pr i ce> </ wi ne> @ grape category (subelement ). grape category xsl :value-of (, XSLT xsl :value-of select, ). <!- - xq33.xsl : conver t s xq31.xml i nt o xq32.xml. - -> <xsl :t empl at e mat ch="wi ne"> <wi ne v i nt age="{ ye ar} "> <pr oduct ><xsl :appl y- t empl at es sel ect ="pr oduct " / ></ pr oduct > <c at e gor y><xs l :v al ue - of s el e ct ="@grape"/ ></ cat egory> <pr i ce><xsl :appl y- t empl at es sel ect ="pr i ce" / ></ pr i ce> </ wi ne> </ xsl :t empl at e>
42 PART 1 XSLT, ( year )., wine year wine vintage =.. XSLT. grape Cabernet wine, wine ( [@grape = Caberbet ] (predicate) XPath ).. grape Cabernet wine. <!- - xq34.xsl - -> <xsl :St yl esheet xml ns :xsl ="ht tp:/ / www.w3. org/ 1999/ XSL/ Transform" ver si on=" 1. 0"> <xsl :t empl at e mat ch="wi ne[ @gr ape= ' Caber net '] "> <xsl :copy><xsl :appl y- t empl at es/ ></ xsl :copy> </ xsl :t empl at e> <xsl :t empl at e mat ch="wi ne" / > <xsl :template mat ch=" @* node () processing-instruction () comment ()"> <xsl :copy> <xsl :appl y- t empl at es sel ect=" @* node () processing-inst ruct i on () comment ()" /> </ xsl :copy> </ xsl :t empl at e> </ xsl :St yl esheet >?.. XML.,,.
CHAPTER 1 XSLT 43. 2 XPath 3.5 3.8 3.14 1.4 XSLT - XSLT 80%.,. DTD XML XML..,.,,. XSLT.
44 PART 1 XSLT, XSLT.. XSLT chapter. <book><t i t l e>par adi se Lost </ t i t l e> <chapt er><t i t l e>the Whi t ene s s of t he Whal e</ t i t l e> <para>he l i ght s, i f i t were Land that ever burned</ para> <par a>wi t h sol i d, as t he Lake wi t h l i qui d f i r e</ par a> </ chapt er> <chapt er><t i t l e>the Cas t away</ t i t l e> <para>ni ne t imes t he Space t hat measures Day and Ni ght</ para> <para>to mort al men, he wi t h hi s horr i d crew</ para> </ chapt er> </ book>. <!- - xq37.xsl - -> <xsl :t empl at e mat ch=" t i t l e"> Ti t l e : <xsl :appl y- t empl at es/ > </ xsl :t empl at e> <xsl :t empl at e mat ch=" chapt er / t i t l e"> Chapt er t i t l e : <xsl :appl y- t empl at es/ > </ xsl :t empl at e> ( chapter/ title title chapter. title ) [ 1.7].. chapter title.. 1. XSLT chapter title. 2..,.
CHAPTER 1 XSLT 45 3.,. 4... Chapter title :, xsl :apply-templates The Whiteness of the Whale (, title ). 1.7 XSLT n ode, XSLT. XSLT, 2 XSLT. 2 XPath 3 3.6 5.1 6.1 HTML XSLT 6.5 XML 6.6 6.9 DOCTYPE valid XML
46 PART 1 XSLT, xsl:message.., terminate (xsl :message, 5.4.1, ).