1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Kỹ thuật lập trình >

Why Does HTML “<“ Conversion Work in oraxsl But Not in XSLSample.java?

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.26 MB, 774 trang )


Frequently Asked Questions About the XSLT Processor and XSL



Even more confusing is that it works with oraxsl, but not with

XSLSample.java.

Answer: Here's why:

s



s



oraxsl internally uses void XSLProcessor.processXSL

(style,source,printwriter);

XSLSample.java uses DocumentFragment XSLProcessor.processXSL

(style,source);



The former supports and all options related to writing output that

might not be valid XML (including the disable output escaping). The latter is pure

XML-to-XML tree returned, so no or disabled escaping can be used

since nothing's being output, just a DOM tree fragment of the result is being

returned.



Where Can I Find XSLT Examples?

Is there any site which has good examples or short tutorials on XSLT?

Answer: This site is an evolving tutorial on lots of different XML, XSLT, and

XPath-related subjects:

http://zvon.vscht.cz/ZvonHTML/Zvon/zvonTutorials_en.html



Where Can I Find a List of XSLT Features?

Is there a list of features of the XSLT that the Oracle XDK uses?

Answer: Our version 2 parsers support the W3C Recommendation of w3c XSLT

version 1.0, which you can see at http://www.w3.org/TR/XSLT.



How Do I Use XSL to Convert an XML Document to Another Form?

I am in the process of trying to convert an XML document from one format to

another by means of an XSL (or XSLT) stylesheet. Before incorporating it into my

Java code, I tried testing the transformation from the command line:

> java oracle.xml.parser.v2.oraxsl jwnemp.xml jwnemp.xsl newjwnemp.xml



The problem is that instead of returning the transformed XML file

(newjwnemp.xml), the above command just returns a file with the XSL code from

jwnemp.xsl in it. I cannot figure out why this is occurring. I have attached the two

input files.



5-18



Oracle9i XML Developer’s Kits Guide - XDK



Frequently Asked Questions About the XSLT Processor and XSL









7950

CLINTON

PRESIDENT

1111

20-JAN-93

125000

1000

10





































Answer: This is occurring most likely because you have the wrong XSL namespace

URI for your xmlns:xsl="..." namespace declaration.

If you use the following URI:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"



then everything will work.

If you use xmlns:xsl="-- any other string here --” it will do what

you're seeing.



XSLT Processor for Java 5-19



Frequently Asked Questions About the XSLT Processor and XSL



Where Can I Find More Information on XSL?

I cannot find anything about using XSL. Can you help? I would like to get an XML

and XSL file to show my company what they can expect from this technology. XML

alone is not very impressive for users.

Answer: A pretty good starting place for XSL is the following page:

http://metalab.unc.edu/xml/books/bible/updates/14.html

It provides a simple discussion of the gist of XSL. XSL isn't really anything more

than an XML file, so I don't think that it will be anymore impressive to show to a

customer. There's also the main Web site for XSL which is:

http://www.w3.org/style/XSL/



Can the XSL Processor Produce Multiple Outputs?

I recall seeing discussions about the XSL processor producing more than one result

from one XML and XSL. How can this can be achieved?

Answer: The XML Parser version 2 release 2.0.2.8 and above supports

to handle this.



5-20



Oracle9i XML Developer’s Kits Guide - XDK



6

XML Schema Processor for Java

This chapter contains the following sections:

s



Introducing XML Schema



s



Oracle XML Schema Processor for Java Features



s



XML Schema Processor for Java Usage



s



How to Run the XML Schema for Java Sample Program



XML Schema Processor for Java 6-1



Introducing XML Schema



Introducing XML Schema

XML Schema was created by the W3C to describe the content and structure of XML

documents in XML. It includes the full capabilities of DTDs (Document Type

Descriptions) so that existing DTDs can be converted to XML Schema. XML

Schemas have additional capabilities compared to DTDs.



How DTDs and XML Schema Differ

Document Type Definition (DTD) is a mechanism provided by XML 1.0 for

declaring constraints on XML markup. DTDs allow the specification of the

following:

s



Which elements can appear in your XML documents



s



What elements can be in the elements



s



The order the elements can appear



XML Schema language serves a similar purpose to DTDs, but it is more flexible in

specifying XML document constraints and potentially more useful for certain

applications. See the following section "DTD Limitations".

Consider the XML document:





2000

The Cat in the Hat

Dr. Seuss

Ms. Seuss

123456781111





Consider a typical DTD for the foregoing XML document:






...



6-2



publisher (year,title, author+, artist?, isbn)>

publish-year (#PCDATA)>

title (#PCDATA)>

author (#PCDATA)>

isbn (#PCDATA)>



Oracle9i XML Developer’s Kits Guide - XDK



XML Schema Features



DTD Limitations

DTDs, also known as XML Markup Declarations, are considered to be deficient in

handling certain applications including the following:

s



Document authoring and publishing



s



Exchange of metadata



s



E-commerce



s



Inter-database operations



DTD limitations include:

s



s



s



DTD is not integrated with Namespace technology so users cannot import and

reuse code

DTD does not support data types other than character data, a limitation for

describing metadata standards and database schemas

Applications need to specify document structure constraints more flexibly than

the DTD allows for



XML Schema Features

Table 6–1, "XML Schema Features" lists XML Schema features. Note that XML

Schema features include DTD features.

Table 6–1 XML Schema Features

XML Schema Feature



DTD



Built-In Data Types

XML schema specifies a set of builtin datatypes. Some of

them are defined and called primitive datatypes, and they

form the basis of the type system:



DTDs do not support data

types other than character

strings.



string, boolean, float, decimal, double, duration, dateTime,

time, date, gYearMonth, gYear, gMonthDat, gMonth, gDay,

Base64Binary, HexBinary, anyURI, NOTATION, QName.

Others are derived datatypes that are defined in terms of

primitive types.



XML Schema Processor for Java 6-3



XML Schema Features



Table 6–1 XML Schema Features (Cont.)

XML Schema Feature



DTD



User-Defined Data Types

Users can derive their own datatypes from the builtin data

types. There are three ways of datatype derivation:

restriction, list and union. Restriction defines a more

restricted data type by applying constraining facets to the

base type, list simply allows a list of values of its item type,

and union defines a new type whose value can be of any of

its member types.

For example, to specify that the value of publish-year type to

be within a specific range:













The constraining facets are:

length, minLength, maxLength, pattern, enumeration,

whiteSpace, maxInclusive, maxExclusive, minInclusive,

minExclusive, totalDigits, fractionDigits.

Some facets only apply to certain base types.

Note that several facets have been changed since the first release of

Oracle XML Schema Processor for Java.



6-4



Oracle9i XML Developer’s Kits Guide - XDK



The publish-year element in

the DTD example cannot be

constrained further.



XML Schema Features



Table 6–1 XML Schema Features (Cont.)

XML Schema Feature



DTD



Control by DTDs over the

number of child elements in

In XML Schema, the structure (called complexType) of the

an element are assigned

instance document or an element is defined in terms of model

with the following symbols:

group and attribute group. A model group may further

s

? = zero or one. In the

contain model groups or element particles, while attribute

foregoing DTD

group contains attributes. Wildcards can be used in both

example, artist? implied

model group and attribute group to indicate any element or

artist is optional - there

attribute. There are three varies of model group: sequence,

may or may not be an

all, and choice, representing the sequence, conjunction and

artist.

disjunction relationships among particles respectively. The

range of the number of occurrence of each particle can also be

s

* = zero or more

specified.

s

+ = one or more (in the

Like the data type, complexType can be derived from other

foregoing DTD

types. The derivation method can be either restriction or

example, author+

extension. The derived type inherits the content of the base

implies more than one

type plus corresponding modifications. In addition to

author is possible)

inheritance, a type definition can make references to other

components. This feature allows a component being defined s

(none) = exactly one

once and used in many other structures.

Occurrence Indicators (Content Model or Structure)



The type declaration and definition mechanism in XML

Schema is much more flexible and powerful than the DTD.

Identity Constraints

XML Schema extends the concept of XML ID/IDREF

mechanism with the declarations of unique, key and keyref.

They are part of the type definition and allow not only

attributes, but also element contents as keys. Each constraint

has a scope within which it holds and the comparison is in

terms of their value rather than lexical strings.

Import/Export Mechanisms (Schema Import, Inclusion



and Modification)

All components of a schema need not be defined in a single

schema file. XML Schema provides a mechanism of

assembling multiple schemas. Import is used to integrate

schemas of different namespace while inclusion is used to

add components of the same namespace. Components can

also be modified using redefinition when included.



You cannot use constructs

defined in external schemas.



XML Schema can be used to define a class of XML documents. “Instance document”

describes an XML document that conforms to a particular schema.



XML Schema Processor for Java 6-5



Oracle XML Schema Processor for Java Features



Although these instances and schemas need not exist specifically as “documents”,

they are commonly referred to as files. They may exist as any of the following:

s



Streams of bytes



s



Fields in a database record



s



Collections of XML Infoset “Information Items”

See Also:



http://www.w3.org/TR/xmlschema-0/



s



s



s



Appendix A, "XDK for Java: Specifications and Quick

References"

Oracle9i XML API Reference - XDK and Oracle XML DB



Oracle XML Schema Processor for Java Features

Oracle XML Schema Processor for Java has the following features:

s



s



s



Supports streaming (SAX) precessing, constant memory usage, and linear

processing time.

Built on the Oracle XML Parser for Java v2

Fully supports the W3C XML Schema specifications of the Candidate

Recommendation (October 24, 2000) and the Recommendation (May 2, 2001).

s



XML Schema Part 0: Primer



s



XML Schema Part 1: Structures



s



XML Schema Part 2: Datatypes



Supported Character Sets

XML Schema Processor for Java supports documents in the following encodings:

s



s



EBCDIC-CP-*



s



EUC-JP



s



EUC-KR



s



6-6



BIG



GB2312



Oracle9i XML Developer’s Kits Guide - XDK



Oracle XML Schema Processor for Java Features



s



ISO-2022-JP



s



ISO-2022-KR



s



ISO-8859-1to -9



s



ISO-10646-UCS-2



s



ISO-10646-UCS-4



s



KOI8-R



s



Shift_JIS



s



US-ASCII



s



UTF-8



s



UTF-16



What’s Needed to Run XML Schema Processor for Java

To run XML Schema Processor for Java, you need the following:

s



Operating Systems: Any OS with Java 1.1.x support



s



Java: JDK 1.1.x. or above.



Online Documentation

Documentation for Oracle XML Schema Processor for Java is located in the doc/

directory in your install area.



Release Specific Notes

The readme.html file in the root directory of the archive, contains release specific

information including bug fixes, and API additions.

Oracle XML Schema Processor is an early adopter release and is written in Java. It

includes the production release of the XML Parser for Java v2.



XML Schema Processor for Java Directory Structure

Table 6–2 lists the directory structure after installing XML Schema Processor for

Java.



XML Schema Processor for Java 6-7



XML Schema Processor for Java Usage



Table 6–2 Directory Structure for an Installation of XML Schema Processor

Directory and File



Description



license.html



copy of license agreement



readme.html



release and installation notes



doc



directory for documents



lib



directory for class files



sample



directory for sample code files



XML Schema Processor for Java Usage

As shown in Figure 6–1, Oracle’s XML Schema processor performs two major tasks:

s



A builder assembles schema from schema XML documents



s



A validator use the schema to validate instance document.



When building the schema, the builder first calls the DOM Parser to parse the

schema XML documents into corresponding DOM trees. It then compiles them into

an internal schema object. The validator works as a filter between the SAX parser

and your applications for the instance document. The validator takes SAX events of

the instance document as input and validates them against the schema. If the

validator detects any invalid XML component it sends an error message. The output

of the validator is:

s



Input SAX events



s



Default values it supplies



s



Post-Schema Validation (PSV) information



Modes for Schema Validation

The XML Parser supports various modes for schema or DTD validation. The

setValidationMode method allows different validation parameters to be set. For

schema validations, there are these modes available:

s



6-8



SCHEMA_VALIDATION. With this mode, the schema validator locates and

builds schemas and validates the whole or a part of the instance document

based on the schemaLocation and noNamespaceSchemaLocation

attributes. See code example XSDSample.java.



Oracle9i XML Developer’s Kits Guide - XDK



Xem Thêm
Tải bản đầy đủ (.pdf) (774 trang)

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×