Now I am trying to make a xsd file based on xml just as below (the xml almost not editable):
<?xml version="1.0" encoding="utf-8" ?>
<root>
<myname>
<description>
<mystring xml:lang="en"></mystring>
<mystring xml:lang="fr"></mystring>
</description>
</myname>
</root>
There is no problem to generate a test.xsd using a xml edit tool, but when bind the xml with the xsd add namespace like this
<root xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test.xsd">
</root>
It not works, show error Attribute 'xml:lang' is not allowed to appear in element 'mystring'
Seems the attribute xml:lang is integrated in xml? How can i use it im my custom element attribute?
I am totally new with xml, greatly appreciate it if anybody could offer some advice...
to enbale the attibute xml:lang in my xml and xsd file
You need to import the schema https://www.w3.org/2001/xml.xsd. And see https://www.w3.org/2001/xml.xsd#ann_3 how to use the imported attribute declaration(s) or declaration group(s).
Also keep in mind that for W3C resources like schemas and DTD it is better to use a local copy, often easily done with a catalog that maps W3C URIs to local file system URIs.