当前位置:首页 > 工业技术
用Java处理XML

用Java处理XMLPDF格式文档图书下载

工业技术

  • 购买点数:27
  • 作 者:(美)阿兰编著
  • 出 版 社:北京:科学出版社
  • 出版年份:2004
  • ISBN:7030124650
  • 标注页数:1072 页
  • PDF页数:1107 页
图书介绍:本书主要讲述企业Java 2平台(J2EE)关键技术的模式、最佳实践、设计策略和经过验证的解决方案。涉及J2EE包括的15个模式的分类和大量的策略,便于读者更好地掌握Java技术。

查看更多关于用Java处理XML的内容

图书介绍
标签:编著 处理

Part Ⅰ XML 1

Chapter 1 XML for Data 3

Motivating XML 3

A Thought Experiment 4

Example 1.2 An XML Document That Indicates an Order for 12 Birdsong Clocks,SKU 244 5

List of ExamplesExample 1.1 A Plain Text Document That Indicates an Order for 12 Birdsong Clocks,SKU 244 5

Example 1.3 A Document That Indicates an Order for 12 Birdsong Clocks, SKU 244 6

Robustness 6

Example 1.4 Still an Order for 12 Birdsong Clocks, SKU 244 7

Extensibility 9

Example 1.5 An XML Document That Indicates an Order for Multiple Products Shipped to Multiple Addresses 10

Ease-of-Use 11

XML Syntax 13

XML Documents 13

ContentsList of Examples 13

XML Applications 15

Elements and Tags 16

Text 19

Attributes 21

XML Declaration 22

List of Figures 23

Comments 23

Processing Instructions 24

Preface 25

Entities 25

Who You Are 27

What You Need to Have 28

What You Need to Know 28

Namespaces 28

How to Use This Book 29

Some Grammatical Notes 30

Example 1.7 An XML Document That Uses Two Default Namespaces 30

Example 1.6 An XML Document That Uses a Default Namespace 30

The Online Edition 30

Contacting the Author 32

Validity 32

DTDs 32

Acknowledgments 33

Example 1.8 A DTD for Order Documents 35

Schemas 37

Example 1.9 order.xsd: A Schema for Order Documents 38

Example 1.10 order.sct: A Schematron Schema for Order Documents 41

Schematron 41

The Last Mile 43

Stylesheets 43

CSS 44

Example 1.11 A CSS Stylesheet for Order Documents 45

Associating Stylesheets with XML Documents 45

List of FiguresFigure 1.1 The Clock Order, Styled Using CSS 46

XSL 46

Example 1.12 An XSLT Stylesheet for Order Documents 48

Example 1.13 An XSL-FO Document for the Clock Order 51

Figure 1.2 The PDF Version of the Clock Order Produced by XSL 51

Summary 53

Chapter 2 XML Protocols: XML-RPC and SOAP 57

XML as a Message Format 58

Envelopes 58

Data Representation 59

Example 2.1 An XML Document That Labels Elements with Schema Simple Types 63

HTTP as a Transport Protocol 64

How HTTP Works 65

Figure 2.1 Slashdot Headlines in XML 66

HTTP in Java 68

Example 2.2 URLGrabber 69

Example 2.3 URLGrabberTest 72

RSS 73

Example 2.4 An RSS 0.91 Document 73

Example 2.5 An RSS 1.0 Document 75

Customizing the Request 77

Query Strings 77

Figure 2.2 NASDAQ Stock Data Retrieved via a Query String 79

How HTTP POST Works 81

XML-RPC 82

Example 2.6 An XML-RPC Request Document 83

Example 2.7 POSTing an XML-RPC Request Document 84

Example 2.8 An XML-RPC Response 84

Data Structures 85

Example 2.9 An XML-RPC Request That Passes an Array as an Argument 86

Example 2.10 An XML-RPC Response Document That Returns an Array 87

Example 2.11 An XML-RPC Request That Passes a Struct as an Argument 88

Example 2.12 An XML-RPC Fault 89

Faults 89

Validating XML-RPC 90

Example 2.13 A DTD for XML-RPC 90

Example 2.14 A Schema for XML-RPC 92

SOAP 96

A SOAP Example 97

Example 2.16 A SOAP Response 97

Example 2.15 A SOAP Document That Requests the Current Stock Price of Red Hat 97

Posting SOAP Documents 98

Example 2.17 A SOAP Request for the Current Stock Price of Red Hat 98

Example 2.18 A SOAP Document That Returns the Current Stock Price of Red Hat 99

Faults 100

Encoding Styles 102

Example 2.19 A SOAP Fault Response 102

Example 2.20 A SOAP Document That Specifies the Encoding Style 103

Example 2.21 A Schema That Assigns Type to Elements in the http://namespaces.cafeconleche.org/xmljava/ch2/Namespace 103

SOAP Headers 112

Example 2.22 A SOAP Request with a Digital Signature in the Header 113

Example 2.23 A SOAP Request with Two Header Entries 114

Example 2.24 A SOAP Request with a mustUnderstand Attribute 115

SOAP Limitations 116

Validating SOAP 117

Example 2.25 A Master Schema for SOAP Trading Documents 117

Custom Protocols 118

Summary 119

Chapter 3 Writing XML with Java 121

Fibonacci Numbers 122

Example 3.1 A Program That Calculates the Fibonacci Numbers 123

Writing XML 124

Example 3.2 The First Ten Fibonacci Numbers in an XML Document 124

Example 3.3 A Program That Outputs the Fibonacci Numbers as an XML Document 125

Better Coding Practices 125

Example 3.4 Using Named Constants for Element Names 126

Example 3.5 A Java Program That Writes an XML Document Which Uses Attributes 127

Attributes 127

Producing Valid XML 128

Example 3.6 A Java Program That Generates a Valid Document 128

Namespaces 130

Example 3.7 A MathML Document That Contains Fibonacci Numbers 130

Example 3.8 A Java Program That Generates a MathML Document 131

Output Streams, Writers, and Encodings 132

Example 3.9 A Java Program That Writes an XML File 133

A Simple XML-RPC Client 139

Example 3.10 Connecting an XML-RPC Server with URLConnection 140

A Simple SOAP Client 142

Example 3.11 Connecting to a SOAP Server with URLConnection 143

Servlets 145

Example 3.12 A Servlet That Generates XML 146

Summary 149

Chapter 4 Converting Flat Files to XML 151

The Budget 152

The Model 154

Figure 4.1 The List of Maps Data Structure for the Budget 155

Input 156

Example 4.1 A Class That Parses Comma-Separated Values into a List of HashMaps 157

Determining the Output Format 159

Example 4.2 Naively Reproducing the Original Budget Table Structure in XML 160

Validation 165

Example 4.3 A Schema for the XML Budget Data 166

Attributes 169

Example 4.4 Converting to XML with Attributes 170

Building Hierarchical Structures from Flat Data 174

Example 4.5 A Hierarchical Arrangement of the Budget Data 174

Figure 4.2 A UML Diagram for the Budget Class Hierarchy 178

Example 4.6 The Budget Class 179

Example 4.7 The Agency Class 181

Example 4.8 The Bureau Class 184

Example 4.9 The Account Class 186

Example 4.10 The Subfunction Class 188

Example 4.11 The Driver Class That Builds the Data Structure and Writes It Out Again 189

Alternatives to Java 191

Example 4.12 An XSLT Stylesheet That Converts Flat XML Data to Hierarchical XML Data 193

Imposing Hierarchy with XSLT 193

The XML Query Language 196

Example 4.13 An XQuery That Converts Flat Data to Hierarchical Data 200

Relational Databases 201

Example 4.14 A Program That Connects to a Relational Database UsingJDBC and Converts the Table to Hierarchical XML 203

Summary 208

Chapter 5 Reading XML 211

Example 5.1 A Response from the Fibonacci XML-RPC Server 211

InputStreams and Readers 211

Example 5.2 Reading an XML-RPC Response 214

XML Parsers 216

Choosing an XML API 218

Choosing an XML Parser 222

Available Parsers 226

SAX 229

Example 5.3 A SAX-Based Client for the Fibonacci XML-RPC Server 230

Example 5.4 The ContentHandler for the SAX Client for the Fibonacci XML-RPC Server 232

DOM 234

Example 5.5 A DOM-Based Client for the Fibonacci XML-RPC Server 235

JAXP 238

Example 5.6 A JAXP-Based Client for the Fibonacci XML-RPC Server 239

JDOM 242

Example 5.7 A JDOM-Based Client for the Fibonacci XML-RPC Server 243

dom4j 246

Example 5.8 A dom4j-Based Client for the Fibonacci XML-RPC Server 246

ElectricXML 248

Example 5.9 An ElectricXML-Based Client for the Fibonacci XML-RPC Server 249

XMLPULL 251

Example 5.10 An XMLPULL-Based Client for the Fibonacci XML-RPC Server 252

Summary 254

Part Ⅱ SAX 257

Chapter 6 SAX 259

What Is SAX? 259

Parsing 260

Example 6.1 A SAX Program That Parses a Document 262

Callback Interfaces 264

Example 6.2 The SAX ContentHandler Interface 264

Implementing ContentHandler 265

Example 6.3 A SAX ContentHandler That Writes All #PCDATA onto a java.io.Writer 266

Using the ContentHandler 267

Example 6.4 The Driver Method for the Text Extractor Program 268

Example 6.5 A Subclass of DefaultHandler That Writes All #PCDATA onto a java.io.Writer 270

The DefaultHandler Adapter Class 270

Receiving Documents 271

Example 6.6 A ContentHandler Interface That Resets Its Data Structures Between Documents 272

Receiving Elements 273

Example 6.7 A ContentHandler Class That Builds a GUI Representation of an XML Document 275

Figure 6.1 The Swing-Based TreeViewer 278

Handling Attributes 279

Example 6.8 The SAX Attributes Interface 279

Example 6.9 A ContentHandler Class That Spiders XLinks 281

Receiving Characters 284

Example 6.10 A SAX Client for the Fibonacci XML-RPC Server 285

Receiving Processing Instructions 288

Example 6.11 A ContentHandler That Prints Processing Instruction Targets and Data on System.out 290

Receiving Namespace Mappings 291

Example 6.12 The NamespaceSupport Class 292

Example 6.13 A Document That Uses Ignorable White Space to Prettify the XML 295

"Ignorable White Space" 295

Receiving Skipped Entities 296

Example 6.14 An XML Document Containing a Potentially Skipped Entity Reference 296

Receiving Locators 298

Example 6.15 The SAX Locator Interface 299

Example 6.16 Determining the Locations of Events 300

What the ContentHandler Doesn't Tell You 303

Summary 304

Building Parser Objects 305

Chapter 7 The XMLReader Interface 305

InputSource 309

Input 309

Example 7.1 The SAX InputSource Class 310

EntityResolver 312

Example 7.2 The EntityResolver Interface 313

Example 7.3 An XHTML EntityResolver 313

Exceptions and Errors 315

SAXExceptions 316

Example 7.4 The SAXException Class 316

Example 7.5 The SAXParseException Class 318

Example 7.6 A SAX Program That Parses a Document and Identifies the Line Numbers of Any Well-Formedness Errors 319

The ErrorHandler Interface 321

Example 7.7 The ErrorHandler Interface 321

Example 7.8 A SAX Program That Reports All Problems Found in an XML Document 322

Features and Properties 325

Getting and Setting Features 325

Getting and Setting Properties 326

Required Features 327

Standard Features 330

Example 7.9 A SAX Program That Validates Documents 331

Standard Properties 335

Example 7.10 A SAX Program That Echoes the Parsed Document 336

Example 7.11 The LexicalHandler Interface 339

Example 7.12 An Implementation of the LexicalHandler Interface 340

Example 7.13 The DeclHandler Interface 343

Example 7.14 A Program That Prints Out a Complete DTD 344

Xerces Custom Features 347

Example 7.15 Making Maximal Use of Xerces' Special Capabilities 350

Xerces Custom Properties 353

Example 7.16 The DTDHandler Interface 355

DTDHandler 355

Example 7.17 A Caching DTDHandler 356

Example 7.18 A Notation Utility Class 357

Example 7.19 An UnparsedEntity Utility Class 359

Example 7.20 A Program That Lists the Unparsed Entities and Notations Used in an XML Document 362

Summary 365

Chapter 8 SAX Filters 367

The Filter Architecture 367

Figure 8.2 XML Parsing with a Filter 368

Figure 8.1 The XML Parsing Process 368

Figure 8.3 XML Parsing with Multiple Filters 369

The XMLFilter Interface 370

Example 8.2 A Filter That Blocks All Events 370

Example 8.1 The XMLFilter Interface 370

Example 8.3 A Filter That Filters Nothing 373

Example 8.4 A Filter That Times All Parsing 378

Example 8.5 Parsing a Document through a Filter 382

Content Filters 384

Filtering Tags 384

Example 8.6 A ContentHandler Filter 385

Example 8.7 A Filter That Substitutes Its Own ContentHandler 388

Example 8.8 A Program That Filters Documents 390

Figure 8.4 How Data Flows through the RDDLStripper Program 393

Filtering Elements 393

Example 8.9 A ContentHandler Filter That Throws Away Non-XHTML Elements 394

Example 8.10 The Attributeslmpl Helper Class 397

Filtering Attributes 397

Filters That Add Content 399

Example 8.11 Changing One Element into Another 401

Filters versus Transforms 405

Figure 8.5 The End of the RDDL Specification as Normally Presented 406

The XMLFilterlmpl Class 407

Figure 8.6 The End of the RDDL Specification after Small Tables Have Replaced rddl:resource Elements 407

Example 8.12 A Subclass of XMLFilterImpl 409

Parsing Non-XML Documents 411

Example 8.13 Accessing Databases through SAX 412

Example 8.14 A Very Simple User Interface for Extracting XML Data from a Relational Database 418

Multihandler Adapters 420

Example 8.15 Attaching Multiple Handlers of the Same Type to a Single Parser 422

Summary 428

Part Ⅲ DOM 431

Chapter 9 The Document Object Model 433

The Evolution of DOM 434

DOM Modules 435

Example 9.1 Which Modules Does Oracle Support? 437

Application-Specific DOMs 439

Trees 440

Document Nodes 442

Example 9.2 An XML-RPC Request Document 442

Element Nodes 443

Attribute Nodes 444

Leaf Nodes 445

Nontree Nodes 447

What Is and Isn't in the Tree 449

DOM Parsers for Java 452

Parsing Documents with a DOM Parser 455

Example 9.3 A Program That Uses Xerces to Check Documents for Well-Formedness 456

Example 9.4 A Program That Uses the Oracle XML Parser to Check Documents for Well-Formedness 457

JAXP DocumentBuilder and DocumentBuilderFactory 458

Example 9.5 A Program That Uses JAXP to Check Documents for Well-Formedness 459

Example 9.6 A Program That UsesJAXP to Check Documents for Well-Formedness 463

DOM3 Load and Save 466

Example 9.7 A Program That Uses DOM3 to Check Documents for Well-Formedness 466

Example 9.8 The Node Interface 468

The Node Interface 468

Node Types 470

Example 9.9 Changing Short Type Constants to Strings 471

Node Properties 472

Example 9.10 A Class to Inspect the Properties of a Node 473

Navigating the Tree 475

Example 9.11 Walking the Tree with the Node Interface 475

Modifying the Tree 478

Example 9.12 A Method That Changes a Document by Reordering Nodes 479

Utility Methods 481

The NodeList Interface 482

Example 9.13 The NodeList Interface 482

JAXP Serialization 483

Example 9.14 Using JAXP to Read and Write an XML Document 484

Example 9.15 The DOMException Class 486

DOMException 486

Choosing between SAX and DOM 489

Summary 492

Chapter 10 Creating XML Documents with DOM 493

DOMImplementation 493

Example 10.1 The DOMImplementation Interface 494

Locating a DOMImplementation 495

Implementation-Specific Class 495

JAXP DocumentBuilder 496

DOM3 DOMImplementa?ionRegist ry 497

Example 10.2 The DOMImplementationRegistry Class 497

The Document Interface as an Abstract Factory 499

Example 10.3 The DOMImplementationSource Interface 499

Example 10.4 The Document Interface 499

Example 10.5 Using DOM to Build an SVG Document in Memory 502

Example 10.6 A DOM Program That Outputs the Fibonacci Numbers as an XML Document 506

Example 10.8 A DOM Program That Outputs the Fibonacci Numbers as a MathML Document 509

Example 10.7 A Valid MathML Document That Contains Fibonacci Numbers 509

Example 10.9 A Valid MathML Document That Uses Prefixed Names 512

The Document Interface as a Node Type 513

Getter Methods 513

Example 10.10 The Properties of a Document Object 515

Finding Elements 517

Example 10.12 An XML-RPC Response Document 518

Example 10.11 An XML-RPC Request Document 518

Example 10.13 A DOM-Based XML-RPC Servlet 519

Example 10.14 A DOM-Based SOAP Servlet 527

Transferring Nodes between Documents 533

Normalization 534

Summary 538

The Element Interface 539

Chapter 11 The DOM Core 539

Example 11.1 The Element Interface 540

Extracting Elements 541

Example 11.2 Extracting Examples from DocBook 543

Attributes 548

Example 11.4 A DOM Program That Adds Attributes 549

Example 11.3 A Document That Uses Attributes 549

The NamedNodeMap Interface 551

Example 11.5 The NamedNodeMap Interface 551

Example 11.6 An XLink Spider That Uses DOM 553

The CharacterData Interface 558

Example 11.7 The CharacterData Interface 559

Example 11.8 Rot-13 Encoder for XML Documents 560

The Text Interface 563

Example 11.9 The Text Interface 564

Example 11.10 Printing the Text Nodes in an XML Document 565

The CDATASection Interface 568

Example 11.11 The CDATASection Interface 568

Example 11.12 Merging CDATA Sections with Text Nodes 569

Example 11.13 The EntityReference Interface 571

The EntityReference Interface 571

Example 11.14 Inserting Entity References into a Document 572

The Attr Interface 573

Example 11.15 The Attr Interface 574

Example 11.16 Specifying All Attributes 575

The ProcessingInstruction Interface 576

Example 11.17 The ProcessingInstruction Interface 577

Example 11.18 Reading PseudoAttributes from a ProcessingInstruction 578

The Comment Interface 581

Example 11.19 The Comment Interface 581

Example 11.20 A DOM Program That Prints Comments 582

The DocumentType Interface 584

Example 11.21 The DocumentType Interface 585

Example 11.22 The Entity Interface 586

The Entity Interface 586

Example 11.23 Listing Parsed Entities Used in the Document 587

The Notation Interface 590

Example 11.24 The Notation Interface 590

Example 11.25 Listing the Notations Declared in a DTD 591

Summary 594

NodeIterator 597

Chapter 12 The DOM Traversal Module 597

Example 12.1 The NodeIterator Interface 598

Constructing NodeIterators with DocumentTraversal 599

Example 12.2 The DocumentTraversal Factory Interface 600

Example 12.3 Using a NodeIterator to Extract All of the Comments from a Document 601

Liveness 603

Example 12.4 Using a NodeIterator to Retrieve the Complete Text Content of an Element 604

Filtering by Node Type 604

NodeFilter 605

Example 12.5 The NodeFilter Interface 606

Example 12.6 An Implementation of the NodeFilter Interface 607

Example 12.7 The TreeWalker Interface 610

TreeWalker 610

Example 12.8 The ExampleFilter Class 612

Example 12.9 Navigating a Subtree with TreeWalker 613

Summary 616

Xerces Serialization 617

Chapter 13 Output from DOM 617

OutputFormat 619

Example 13.1 Using Xerces' OutputFormat Class to "Pretty Print" XML 619

Example 13.2 Using Xerces' OutputFormat Class to "Pretty Print" MathML 624

DOM Level 3 627

Example 13.3 The DOM3 DOMWriter Interface 628

Example 13.5 Serializing with DOMWriter 630

Example 13.4 The DOM3 DOMErrorHandler Interface 630

Creating DOMWriters 632

Example 13.6 The DOM3 DOMImplementationLS Interface 632

Example 13.7 An Implementation-lndependent DOM3 Program to Build and Serialize an XML Document 633

Serialization Features 635

Filtering Output 636

Example 13.9 Filtering Everything That Isn't XHTML on Output 637

Example 13.8 The DOMWriterFilter Interface 637

Example 13.10 Using a DOMWriterFilter 639

Summary 640

Part Ⅳ JDOM 641

Chapter 14 JDOM 643

What ls JDOM? 644

Creating XML Elements with JDOM 647

Creating XML Documents with JDOM 649

Writing XML Documents with JDOM 651

Example 14.1 AJDOM Program That Produces an XML Document Containing Fibonacci Numbers 652

Document Type Declarations 656

Example 14.2 A Fibonacci DTD 656

Example 14.3 A JDOM Program That Produces a Valid XML Document 657

Namespaces 659

Example 14.4 A MathML Document Containing the First Three Fibonacci Numbers 659

Example 14.5 A JDOM Program That Uses Namespaces 660

Reading XML Documents with JDOM 664

Example 14.6 A JDOM Program That Uses the Default Namespace 66?Example 14.7 A JDOM Program That Checks XML Documents for Well-Formedness 665

Example 14.8 A JDOM Program That Validates XML Documents 667

Navigating JDOM Trees 668

Example 14.9 A JDOM Program That Lists the Elements Used in a Document 669

Example 14.10 A JDOM Program That Lists the Nodes Used in a Document 672

Talking to DOM Programs 675

Talking to SAX Programs 676

Configuring SAXBuilder 676

Example 14.11 A JDOM Program That Schema Validates Documents 677

SAXOutputter 679

Example 14.12 AJDOM Program That Passes Documents to a SAX ContemHandler 679

Java Integration 681

Serializing JDOM Objects 681

Synchronizing JDOM Objects 681

Testing Equality 681

Hash Codes 682

What JDOM Doesn't Do 683

Cloning 683

String Representations 683

Summary 684

Chapter 15 The JDOM Model 687

The Document Class 688

Example 15.1 TheJDOM Document Class 688

The Element Class 690

Constructors 693

Example 15.2 Inspecting Elements 694

Navigation and Search 694

Example 15.3 An XML-RPC Request Document 700

Example 15.5 The JDOM ContentFilter Class 705

Example 15.4 The JDOM Filter Interface 705

Example 15.6 TheJDOM ElementFilter Class 708

Example 15.7 A Filter for xml-stylesheet Processing Instructions in the Prolog 709

Example 15.8 Moving Elements between Documents 712

Attributes 714

Example 15.9 Searching for RDDL Resources 716

The Attribute Class 719

Example 15.10 The JDOM Attribute Class 720

The Text Class 724

Example 15.11 The JDOM Text Class 724

Example 15.12 JDOM-Based Rot-13 Encoder for XML Documents 726

Example 15.13 The JDOM CDATA Class 729

The CDATA Class 729

The ProcessingInstruction Class 730

Example 15.14 The JDOM ProcessingInstruction Class 731

Example 15.15 The JDOM Comment Class 733

The Comment Class 733

Example 15.16 Printing Comments 734

Namespaces 736

Example 15.17 The JDOM Namespace Class 736

Example 15.18 An XML Document That Uses Namespace Prefixes in Attribute Values 738

The DocType Class 739

Example 15.19 The JDOM DocType Class 740

Example 15.20 Validating XHTML with the DocType Class 743

The EntityRef Class 745

Example 15.21 The JDOM EntityRef Class 745

Summary 748

Part Ⅴ XPath/XSLT 751

Chapter 16 XPath 753

Example 16.1 Weather Data in XML 754

Queries 754

The XPath Data Model 756

Figure 16.1 XPath Explorer 756

Example 16.2 A SOAP Response Document 758

Location Paths 759

Figure 16.2 An XPath Data Model 759

Example 16.3 An XML-RPC Request Document 760

Axes 761

Example 16.4 A SOAP Request Document 762

Node Tests 764

Predicates 766

Compound Location Paths 768

Absolute Location Paths 769

Abbreviated Location Paths 770

Combining Location Paths 772

Expressions 772

Literals 773

Operators 774

Functions 774

XPath Engines 778

XPath with Saxon 781

XPath with Xalan 785

Example 16.5 The Xalan XPathAPI Class 786

DOM Level 3 XPath 789

Example 16.6 The XPathEvaluator Interface 790

Example 16.7 The XPathResult Interface 792

Namespace Bindings 794

Example 16.8 An XML Document That Contains Namespace Bindings and an XPath Search Expression 795

Snapshots 797

Example 16.9 The DOM3 XPathExpression Interface 798

Compiled Expressions 799

Jaxen 804

SummaryChapter 17 XSLT 805

XSL Transformations 805

Template Rules 806

Example 17.1 An XSLT Stylesheet for XML-RPC Request Documents 807

Stylesheets 808

Example 17.2 An XSLT Stylesheet That Echoes XML-RPC Requests 809

Example 17.3 An XML-RPC Request Document 810

Example 17.4 An XML-RPC Response Document 810

Taking the Value of a Node 811

Applying Templates 812

The Default Template Rules 813

Selection 815

Example 17.5 An XSLT Stylesheet That Calculates Fibonacci Numbers 820

Calling Templates by NameTrAX 822

Thread Safety 824

Example 17.6 A Servlet That Uses TrAX and XSLT to Respond to XML-RPC Requests 826

Locating Transformers 827

The xml-stylesheet Processing Instruction 828

Features 831

Example 17.7 Testing the Availability of TrAX Features 832

XSLT Processor Attributes 834

Example 17.9 A URIResolver Class 836

Example 17.8 The TrAX URIResolver Interface 836

URI Resolution 836

Error Handling 837

Example 17.11 An ErrorListener That Uses the Logging API 838

Example 17.10 The TrAX ErrorListener Interface 838

Passing Parameters to Stylesheets 840

Output Properties 842

Example 17.12 The TrAX OutputKeys Class 844

Sources and Results 845

Example 17.14 The TrAX DOMResult Class 846

Example 17.13 The TrAX DOMSource Class 846

Example 17.15 The TrAX SAXSource Class 847

Example 17.16 The TrAX SAXResult Class 848

Example 17.17 The TrAX StreamSource Class 849

Example 17.18 The TrAX StreamResult Class 850

Extending XSLT with Java 850

Example 17.19 A Java Class That Calculates Fibonacci Numbers 851

Extension Functions 851

Example 17.20 The Xalan ExpressionContext Interface 862

Extension Elements 862

Example 17.21 A Stylesheet That Uses an Extension Element 863

Summary 865

Part Ⅵ Appendixes 867

SAX 869

Appendix A XML API Quick Reference 869

org.xml.sax 870

org.xml.sax.ext 880

org.xml.sax.helpers 882

DOM 891

The DOM Data Model 892

org.w3c.dom 894

org.w3c.dom.traversal 908

JAXP 912

javax. xml.parsers 912

javax.xml.transform 917

TrAX 917

javax.xml.transform.stream 924

javax.xml.transform.dom 926

javax.xml.transform.sax 927

org.jdom 930

JDOM 930

org.jdom.filter 947

org.jdom.input 950

org.jdom.output 957

org jdom.transform 962

org.jdom.xpath 964

XMLPULL 964

org.xmlpull.vl 965

Appendix B SOAP 1.1 Schemas 969

The SOAP 1.1 Envelope Schema 969

The SOAP 1.1 Encoding Schema 973

W3C Software Notice and License 986

Appendix C Recommended Reading 989

Books 989

Specifications 990

Index 993

查看更多关于用Java处理XML的内容

相关书籍
作者其它书籍
返回顶部