|
next
|
 Subject: XSLT Problem using Namespace and SchemaLocation Author: (Deleted User) Date: 30 Nov 2005 09:52 AM
|
Naveen,
First, your sample input .xml is not well-formed. You are terminating the response-data-vals element 2 times. The xml should be like this:
<?xml version="1.0" encoding="UTF-8"?>
<response-data xsi:schemaLocation="http://xml-schemas.something.com/sample sample/sampleTest.xsd"
xmlns="http://xml-schemas.something.com/sample"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<response-data-vals lname="Smith" fname="Allen" dob="19500101"/>
</response-data>
Second, we need to get the namespaces to match between the two documents.
In the .xml file, you are specifying the namespace with this attribute:
xmlns="http://xml-schemas.something.com/sample"
The other attributes (xsi:schemaLocation and xmlns:xsi) have nothing to do with this problem. You can delete them or leave them it makes no difference.
In the .xsl file, you are specifying the namespace with this attribute:
xmlns:myns="http://xml-schemas.something.com/sample sample/sampleTest.xsd"
The value is not the same, as in the .xml file. Change it to be this:
xmlns:myns="http://xml-schemas.something.com/sample"
and everything will work.
The important thing is that the value of the xmlns= in the .xml file must match the value of the xmlns:myns= in the .xsl file. You can use any string you want, "http://xml-schemas.something.com/sample" is OK. "blah" is also OK, as long as is is the same in both files.
You seem to be trying to use the name of a schema file as the namespace name. That is also OK, but the fact that it is a schema file is not important. You don't specify a schema using the namespace mechanism.
Hope this helps,
Clyde
|
|
|
|