PHP often has been one of the first languages to implement new technologies.
In the case of XML, PHP first added support back in version 3.06, which
was released in December 1998.
Of course, you'd probably want to set other options as well when you
configure.
Because PHP 4 uses the expat parser, limitations of that parser apply
to PHP. For example, because expat is not a validating parser, PHP's XML
module cannot do any validation against a DTD.
Using Java objects in a pinch
PHP does not have the wide variety of XML tools that are now available
for Java developers and Perl developers. However, PHP 4 includes
support for accessing Java objects, putting the wide variety of Java language
XML tools at the disposal of PHP developers. You don't need to know how
to write Java code to take advantage of this method, although you'll find
it easier if you have some familiarity with Java language calling conventions
(such as method overloading).
PHP's Java language support is new and documentation is not yet available, but
expect this to improve. For now, developers interested in accessing Java
objects need to examine two examples provided within the PHP distribution
(found in the same directory as the Java extension.)
Some problems exist with the interaction between PHP and the Java language.
The Java language's method of overloading is not 100% supported by PHP's
Java extension because the PHP language does not support method
overloading.
The setup process differs slightly for each implementation
of Java objects. See the README file in the ext/java directory of your
PHP distribution. (Only Red Hat 6.1 and Windows NT 4.0 instructions are
included; it is not clear when other operating systems will be
supported.)
When building on a Red Hat Linux 6.1 system with Blackdown?s JDK 1.2.2
RC 4, I did encounter a problem with the PHP configure script that would
not allow me to use just the --with-java option. Instead, I had
to specify the location of the JDK using --with-java=/opt/jdk1.2.2
instead.
be sure to copy or move the php_java.jar file and the libphp_java.so
file into permanent locations (they are not installed as part of the "make
install" process), so they can be referenced in your php.ini configuration
file (as seen in the ext/java README file.)
The following example demonstrates how to call Java objects from within PHP.
Listing 1. Calling Java objects from within PHP
$system = new Java ( "java.lang.System" );
print "Java version: " . $system->getProperty ( "java.version"
) . "<br>\n";
print "Java vendor: " . $system->getProperty ( "java.vendor" ).
"<p>\n";
print "OS: " . $system->getProperty ( "os.name" ) . " " .
$system->getProperty ( "os.version" ) . " on " .
$system->getProperty ( "os.arch" ) . "<br>\n";
Processing stylesheets
|
Developers who want to use XSL to translate XML documents into HTML
will find it difficult to do so in PHP alone. Because the Java language has
many XSLT tools, using the new Java extension will greatly simplify this
task.
|
Parsers and object models: |
| Generic XML parser |
PHP class that uses PHP's XML API to parse arbitrary XML input. |
| PHP RAX |
A PHP port of the XML::RAX Perl module. |
| XMLtree |
Another PHP class used to help parse XML input. |
|
XSLT processors: |
| PHP Sablot extension |
A PHP extension that provides an interface to Sablotron XSLT library. |
|
Protocols: |
| XML-RPC PHP |
Remote procedure calling (RPC) using HTTP as the transport and XML as the encoding. This class implements XML-RPC for PHP. |
| WDDX |
Protocol for the exchange of data between different languages such as Perl, Java, ColdFusion, and PHP. This module converts PHP variables to and from WDDX packets. You must install the WDDX SDK to enable WDDX support in PHP. |
| Horde Projects's Jonah tool |
Protocol for retrieving and parsing RDF/RSS files. RSS (Rich Site Summary) is most often used to represent news items, commonly called channels. |