Académique Documents
Professionnel Documents
Culture Documents
Craig Knudsen
Web Engineer, ePresence, Inc.
June 2000
The PHP scripting language's XML support has a few gaps, but you can fill them with Java Contents:
objects in a pinch. In this article, find out what XML tools are available now for PHP expat in PHP 4
developers looking to craft XML projects, and find out how to access Java objects until the
PHP tool set matures. Working with PHP 3
Looking to the future
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. Using Java objects
Choosing your tools
Building expat into PHP 4
PHP 4.0, which was recently released, uses James Clark's popular C-based expat parser, which is Resources
also the XML parser used by the Mozilla browser. PHP 4 includes expat in the distribution, so About the author
enabling XML support is as simple as using the --enable-xml switch as part of the configuration
step when building PHP as seen below:
./configure --enable-xml -with-apache=../apache_1.3.12
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.
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.
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.
Tools summary
Generic XML parser PHP class that uses PHP's XML API to parse arbitrary 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.
Resources
● Read the PHP Manual's section on XML for installation tips and examples.
● Learn how to use XML-RPC to implement remote procedure calls with PHP in Backends Sharing Data.
● Keep up with the latest XML news and views at XML.com.
● Add your name to the PHP-XML mailing list hosted by The O'Reilly Network.
● Subscribe to the PHP XML-RPC interest mailing list to stay current on all XMP-RPC PHP activities.
● Find XML tools for Java developers in "Java developers: Fill your XML toolbox" on developerWorks.
● Join the exchange in the new (June 2000) PHP-XML newsgroup, or download the contents.
Comments?
Submit feedback