473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Xml, Xschema and php

Someone could tell me how can I validate
an xml file against an Xschema using php?

Thanks and sorry for my little english.

-------------------------------------
"Computer Science is no more about
computers than astronomy is about
telescopes."
::[E. W. Dijkstra]
Jul 17 '05 #1
1 1572
Xaradas wrote:
Someone could tell me how can I validate
an xml file against an Xschema using php?

Thanks and sorry for my little english.

-------------------------------------
"Computer Science is no more about
computers than astronomy is about
telescopes."
::[E. W. Dijkstra]


none of the XML parsing extensions in php (SAX or DOM) do schema/dtd
validation.

Fortunately, this is not a hard limit due to the fact that you can use
other parsers via one of PHP's interfaces to external programs.

You have 3 options in that regard (external validating parsers)
1) use a command-line parser to do the job
2) load an XML parsing java class that supports validation
3) if using windows, load MSXML

For option 1, go see the PHP manual on how to execute external commands.
For option two, you should be able to find some devent parsers at
xml.apache.org. Using java from within PHP is trivial!
For option 3, I ripped this example from the user-contributed notes in
the DOM XML part of the online PHP manual.

krator at krator dot com (05-Nov-2002 01:51)

If you are using php on windows then install MSXML Core Services and use
their tools. This can be done by using the php COM functions.
<?php
$xmlparser = new COM("Microsoft.XMLDOM") or die("Unable to instanciate
MSXML");
echo "Loaded MSXML.\n";
$xmlparser->async="false";
$xmlparser->validateOnParse="true";
$xmlparser->load("d:\\xmldata\\test.xml");
echo "Error Code: ";
echo $xmlparser->parseError->errorCode;
echo "Error Reason: ";
echo $xmlparser->parseError->reason;
echo "Error Line: ";
echo $xmlparser->parseError->line;
?>
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Karl | last post by:
Hi! I'm having trouble with referencing different schemas. I'm not sure how it's supposed to work. When I work on the files, the targetNamespace="www.test.com/schemas/test.xsd" does not exist...
4
by: Binesh Bannerjee | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. In another thread, Martin Honnen <mahotrash@yahoo.de> wrote: > XHTML is XML so there is no problem to use it inside of an XML document e.g. > ...
1
by: Tjerk Wolterink | last post by:
I have an schema, like this one: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.wolterinkwebdesign.com/xml/model"...
0
by: Tjerk Wolterink | last post by:
I want to define an schema that allows the following documents: The name of the elements do not matter, but all the elements should have the following attribute: <xsd:attribute name="type"...
9
by: Tjerk Wolterink | last post by:
I have an xml document that conforms to my xschema document. Now i wanted to use xinclude in my xml document. But when i want to validate the xml document to the xschema i get the following...
4
by: J David Eisenberg | last post by:
One of the students in my XML class is asking what the purpose of validating is in the context of a web application. He's trying to figure out how he would use XML Schema or Relax NG and...
2
by: Tjerk Wolterink | last post by:
I've a element definition like this: -- <xs:element name="content"> <xs:complexType> <xs:sequence> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:any...
1
by: OpticTygre | last post by:
How can I make the following code synchronous? TIA. Public Sub ValidateXMLAgainstSchema(ByVal XSchema As XmlSchema, ByVal XData As String) Dim XSchemaset As XmlSchemaSet = New XmlSchemaSet ...
6
by: N.stolwijk | last post by:
I'm new to writing scheme. And I'm breaking my teeth on this obviously easy one. I would like to write a scheme which validates the following <projects> <project> <id>text</id>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.