预定义类

The XML DAS provides two main classes. The first is SDO_DAS_XML which is the main class used to fetch the data from the XML source and used to write the data back. The second is the SDO_DAS_XML_Document class, which represents the data in the XML document.

There are also some exception classes which can be thrown if errors are found when looking for or parsing the xsd or xml files.

SDO_DAS_XML

This is the main class of the XML DAS, which is used fetch the data from the xml source and also used to write the data back. Other than the methods to load and save xml files,

方法

  • create This is a static method available in the SDO_DAS_XML class. Used to construct an SDO_DAS_XML object.

  • addTypes Works in much the same way as create but used to add the contents of a second or subsequent schema file to an XML DAS that has already been created.

  • createDataObject Can be used to construct an SDO data object of a given type.

  • createDocument Can be used to construct an XML Document object from scratch.

  • loadFile Loads the xml instance document from a file. This file can be at local file system or it can be on a remote host.

  • loadString same as the above method. Loads the xml instance which is available as string.

  • saveFile save SDO_DAS_XML_Document object as a xml file.

  • saveString save SDO_DAS_XML_Document object as a xml string.

SDO_DAS_XML_Document

This class can be used to get to the name and namespace of the document element, and to get to the root data object of the document. Lastly, it can also be used to set the XML version and encoding of a document on output.

方法

SDO_DAS_XML_ParserException

Is a subclass of SDO_Exception. Thrown for any parser errors while loading the xsd/xml file.

SDO_DAS_XML_FileException

Is a subclass of SDO_Exception. Thrown by any of the methods that load data from a file, when the file cannot be found.

Limitations compared with SDO 2.0 specification

The » SDO 2.0 specification defines the mapping between XML types and SDO types. With Java SDO, this mapping is implemented by the XMLHelper. With SDO for PHP, this mapping is implemented by the XML Data Access Service. The XML DAS implements the mapping described in the SDO 2.0 specification with some restrictions. A detailed list is of the limitations is:

XML Simple Types

  1. Simple Type with sdoJava:instanceClass - no PHP equivalent provided.

  2. Simple Type with sdoJava:extendedInstanceClass - no PHP equivalent provided.

  3. Simple Type with list of itemType.

  4. Simple Type with union.

XML Complex Types

  1. Complex Type with sdo:aliasName - no PHP support for SDO Type aliases.

XSD Attribute

  1. Attribute with sdo:aliasName - no PHP support for SDO property aliases.

  2. Attribute with default value - no PHP support for SDO property defaults.

  3. Attribute with fixed value - no PHP support for SDO read-only properties or default values.

  4. Attribute referencing a DataObject with sdo:propertyType - no support for sdo:propertyType="...".

  5. Attribute with bi-directional property to a DataObject with sdo:oppositeProperty and sdo:propertyType - no PHP support for SDO opposite.

XSD Elements

  1. Element with sdo:aliasName - no PHP support for SDO property aliases.

  2. Element with substitution group.

XSD Elements with Simple Type

  1. Element of SimpleType with default - no PHP support for SDO defaults

  2. Element of SimpleType with fixed value - no PHP support for SDO read-only properties or default values.

  3. Element of SimpleType with sdo:string - no support for sdo:string="true".

  4. Element referencing a DataObject with sdo:propertyType - no support for sdo:propertyType="..."

  5. Element with bi-directional reference to a DataObject with sdo:oppositeProperty and sdo:propertyType - no PHP support for SDO opposite.

SDO_DAS_XML::addTypes

To load a second or subsequent schema file to a SDO_DAS_XML object

说明

void SDO_DAS_XML::addTypes ( string $xsd_file )

Load a second or subsequent schema file to an XML DAS that has already been created with the static method create. Although the file may be any valid schema file, a likely reason for using this method is to add a schema file containing definitions of extra complex types, hence the name. See Example 4 of the parent document for an example.

参数

xsd_file
Path to XSD Schema file.

返回值

None if successful, otherwise throws an exception as described below.

错误/异常

SDO_TypeNotFoundException
Thrown if a type is not defined in the underlying model.

SDO_DAS_XML_ParserException
Thrown for any problems while parsing the given XSD File.

SDO_DAS_XML_FileException
Thrown if the specified file cannot be found.

SDO_DAS_XML::create

To create SDO_DAS_XML object for a given schema file

说明

SDO_DAS_XML SDO_DAS_XML::create ([ mixed $xsd_file [, string $key ]] )

This is the only static method of SDO_DAS_XML class. Used to instantiate SDO_DAS_XML object.

参数

xsd_file
Path to XSD Schema file. This is optional. If omitted a DAS will be created that only has the SDO base types defined. Schema files can then be loaded with the addTypes method. Can be string or array of values.

key

返回值

Returns SDO_DAS_XML object on success otherwise throws an exception as described below.

错误/异常

SDO_TypeNotFoundException
Thrown if a type is not defined in the underlying model.

SDO_DAS_XML_ParserException
Thrown for any problems while parsing the given XSD File.

SDO_DAS_XML_FileException
Thrown if the specified file cannot be found.

SDO_DAS_XML::createDataObject

Creates SDO_DataObject for a given namespace URI and type name

说明

SDO_DataObject SDO_DAS_XML::createDataObject ( string $namespace_uri , string $type_name )

Creates SDO_DataObject for a given namespace URI and type name. The type should be defined in the underlying model otherwise SDO_TypeNotFoundException will be thrown.

参数

namespace_uri
Namespace URI of the type name.

type_name
Type Name.

返回值

Returns SDO_DataObject on success.

错误/异常

SDO_TypeNotFoundException
Thrown if a type is not defined in the underlying model.

SDO_DAS_XML::createDocument

Creates an XML Document object from scratch, without the need to load a document from a file or string

说明

SDO_DAS_XML_Document SDO_DAS_XML::createDocument ([ string $document_element_name ] )

SDO_DAS_XML_Document SDO_DAS_XML::createDocument ( string $document_element_namespace_URI , string $document_element_name [, SDO_DataObject $dataobject ] )

Creates an XML Document object. This will contain just one empty root element on which none of the properties will have been set. The purpose of this call is to allow an application to create an XML document from scratch without the need to load a document from a file or string. The document that is created will be as if a document had been loaded that contained just a single empty document element with no attributes set or elements within it.

createDocument may need to be told what the document element is. This will not be necessary in simple cases. When there is no ambiguity then no parameter need be passed to the method. However it is possible to load more than one schema file into the same XML DAS and in this case there may be more than one possible document element defined: furthermore it is even possible that there are two possible document elements that differ only in the namespace. To cope with these cases it is possible to specify either the document element name, or both the document element name and namespace to the method.

参数

document_element_name
The name of the document element. Only needed if there is more than one possibility.

document_element_namespace_URI
The namespace part of the document element name. Only needed if there is more than one possible document element with the same name.

dataobject

返回值

Returns an SDO_XML_DAS_Document object on success.

错误/异常

SDO_UnsupportedOperationException
Thrown if an element name or element name and namespace URI is passed, but not found in the underlying model.

SDO_DAS_XML::loadFile

Returns SDO_DAS_XML_Document object for a given path to xml instance document

说明

SDO_XMLDocument SDO_DAS_XML::loadFile ( string $xml_file )

Constructs the tree of SDO_DataObjects from the given address to xml instance document. Returns SDO_DAS_XML_Document Object. Use SDO_DAS_XML_Document::getRootDataObject method to get root data object.

参数

xml_file
Path to Instance document. This can be a path to a local file or it can be a URL.

返回值

Returns SDO_DAS_XML_Document object on Success or throws exception as described.

错误/异常

SDO_TypeNotFoundException
Thrown if a type is not defined by the underlying model.

SDO_PropertyNotFoundException
Thrown if a property within a type is not defined in the underlying model.

SDO_DAS_XML_ParserException
Thrown for any problems while parsing the given XSD File.

SDO_DAS_XML_FileException
Thrown if the specified file cannot be found.

SDO_DAS_XML::loadString

Returns SDO_DAS_XML_Document for a given xml instance string

说明

SDO_DAS_XML_Document SDO_DAS_XML::loadString ( string $xml_string )

Constructs the tree of SDO_DataObjects from the given xml instance string. Returns SDO_DAS_XML_Document Object. Use SDO_DAS_XML_Document::getRootDataObject method to get root data object.

参数

xml_string
xml string.

返回值

Returns SDO_DAS_XML_Document object on Success or throws exception as described.

错误/异常

SDO_TypeNotFoundException
Thrown if a type is not defined by the underlying model.

SDO_PropertyNotFoundException
Thrown if the a property within a type is not defined in the underlying model.

SDO_DAS_XML_ParserException
Thrown for any problems while parsing the given XSD File.

SDO_DAS_XML::saveFile

Saves the SDO_DAS_XML_Document object to a file

说明

void SDO_DAS_XML::saveFile ( SDO_XMLDocument $xdoc , string $xml_file [, int $indent ] )

Saves the SDO_DAS_XML_Document object to a file.

参数

xdoc
SDO_DAS_XML_Document object.

xml_file
xml file.

indent
Optional argument to specify that the xml should be formatted. A non-negative integer is the amount to indent each level of the xml. So, the integer 2, for example, will indent the xml so that each contained element is two spaces further to the right than its containing element. The integer 0 will cause the xml to be completely left-aligned. The integer -1 means no formatting - the xml will come out on one long line.

返回值

None.

错误/异常

SDO_DAS_XML_FileException
Thrown if the specified file cannot be found.

SDO_DAS_XML::saveString

Saves the SDO_DAS_XML_Document object to a string

说明

string SDO_DAS_XML::saveString ( SDO_XMLDocument $xdoc [, int $indent ] )

Saves the SDO_DAS_XML_Document object to string.

参数

xdoc
SDO_DAS_XML_Document object.

indent
Optional argument to specify that the xml should be formatted. A non-negative integer is the amount to indent each level of the xml. So, the integer 2, for example, will indent the xml so that each contained element is two spaces further to the right than its containing element. The integer 0 will cause the xml to be completely left-aligned. The integer -1 means no formatting - the xml will come out on one long line.

返回值

xml string.

SDO_DAS_XML_Document::getRootDataObject

Returns the root SDO_DataObject

说明

SDO_DataObject SDO_DAS_XML_Document::getRootDataObject ( void )

Returns the root SDO_DataObject.

参数

返回值

Returns the root SDO_DataObject.

SDO_DAS_XML_Document::getRootElementName

Returns root element's name

说明

string SDO_DAS_XML_Document::getRootElementName ( void )

Returns root element's name.

参数

返回值

Returns root element's name.

SDO_DAS_XML_Document::getRootElementURI

Returns root element's URI string

说明

string SDO_DAS_XML_Document::getRootElementURI ( void )

Returns root element's URI string.

参数

返回值

Returns root element's URI string.

SDO_DAS_XML_Document::setEncoding

Sets the given string as encoding

说明

void SDO_DAS_XML_Document::setEncoding ( string $encoding )

Sets the given string as encoding.

参数

encoding
Encoding string.

返回值

None.

SDO_DAS_XML_Document::setXMLDeclaration

Sets the xml declaration

说明

void SDO_DAS_XML_Document::setXMLDeclaration ( bool $xmlDeclatation )

Controls whether an XML declaration will be generated at the start of the XML document. Set to TRUE to generate the XML declaration, or FALSE to suppress it.

参数

xmlDeclatation
Boolean value to set the XML declaration.

返回值

None.

SDO_DAS_XML_Document::setXMLVersion

Sets the given string as xml version

说明

void SDO_DAS_XML_Document::setXMLVersion ( string $xmlVersion )

Sets the given string as xml version.

参数

xmlVersion
xml version string.

返回值

None.

目录