Giving XML File a Relative Link to a Schema?
I have an XML file and I've used Visual 开发者_JAVA百科Studios 2010 to create a basic XML schema for this file. I need to link the two files.
Here is my directory structure:
xml/
.xml
.xml
xsd/
.xsd
.xsd
<root
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="xml_schemas/accounts.xsd"
>
Is it possible to do this? How can I do this? I'm getting an error about needing pairs, the first being the namespace URI and the second being the file location. The xml and xsd are on a local machine only.
Your schema location always needs to be a list of pairs where the first part of the pair is a namespace and the second is a URI.
In your case:
<root
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com ../xsd/accounts.xsd">
In cases of schemas with no namespace, you would use xsi:noNamespaceSchemaLocation
, which contains only a URI.
精彩评论