Cheap Web Hosting for Developers

PHP, MySQL, Java, Unix Cheap Web Hosting

CHAPTER 6 DOCUMENT OBJECT MODEL (DOM) 215

Filed under: PHP and XML — webmaster @ 14:24

CHAPTER 6 DOCUMENT OBJECT MODEL (DOM) 215 It becomes more difficult when building a document manually containing a DTD and performing validation. Internal subsets cannot be created with the DOM extension manually. You can create external subsets using methods from the DOMImplementation class, but these still are not loaded into memory. In these instances, a document should be serialized, reloaded, and then validated in order for validation to work properly. Validating with XML Schemas Validation with XML Schemas is a bit different than working with DTDs. The schema is not loaded at parse time like internal and external subsets are. Associating an XML schema with an XML document is not even performed until validation is ready to be performed. An advantage of this is that it removes the need for any type of document serialization. You can specify XML Schemas either through a string containing the schema or through a URI pointing to the location of the schema. The DOMDocumentclass implements the methods schemaValidate() and schemaValidateSource() to load a schema and validate it against the current document at the same time. Each takes a single parameter. The method schemaValidate() accepts a string containing the URI of the schema; schemaValidateSource() takes a string containing the XML of the schema itself. These methods return the same results as validating against a DTD. A Boolean is returned, and errors from libxml are possible. Each must be handled appropriately. For example: $dom = DOMDocument::loadXML(’ ‘); $schema = ‘ ‘; $isvalid = $dom->schemaValidateSource($schema); var_dump($isvalid);

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Cheap Web Hosting