|
First of all, happy new
year to all!! :)
i've got one doubt 'bout XML vs Mono.Net. i think
my doubt is quite simple:
i've got this XSD
Schema File:
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:dac-entity-conf-2004-v1.0" elementFormDefault="qualified"
targetNamespace="urn:dac-entity-conf-2004-v1.0"> <xsd:element
name="dacEntity" type="dac.Entity"
/> <xsd:complexType
name="dac.Entity"> <xsd:sequence> <xsd:element
name="entitySpecific" type="dac.Entity.Specific"
/> <xsd:element name="dacConfig"
type="dac.Entity.Config"
/> </xsd:sequence> <xsd:attribute
name="id" type="xsd:string" /> <xsd:attribute
name="name" type="xsd:string"
/> </xsd:complexType> <xsd:complexType
name="dac.Entity.Specific"> <xsd:sequence
maxOccurs="1" minOccurs="1"> <xsd:element
name="entityDescription"
type="xsd:string"></xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType
name="dac.Entity.Config"> <xsd:sequence maxOccurs="1"
minOccurs="1"> <xsd:element name="relations"
type="dac.Entity.Config.Relation"></xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType
name="dac.Entity.Config.Relation"> <xsd:sequence
minOccurs="0"
maxOccurs="unbounded"> <xsd:element
name="relation"
type="xsd:string"></xsd:element> </xsd:sequence> <xsd:attribute
name="basens" type="dac.NameSpaces"
/> </xsd:complexType> <xsd:simpleType
name="dac.NameSpaces"> <xsd:restriction
base="xsd:string"> <xsd:enumeration
value="urn:dac-entity-conf-2004-v1.0"
/> <xsd:enumeration
value="urn:dac-group-conf-2004-v1.0"
/> <xsd:enumeration
value="urn:dac-privilege-conf-2004-v1.0"
/> <xsd:enumeration
value="urn:dac-property-conf-2004-v1.0"
/> <xsd:enumeration
value="urn:dac-relation-conf-2004-v1.0"
/> <xsd:enumeration
value="urn:dac-user-conf-2004-v1.0"
/> </xsd:restriction> </xsd:simpleType> </xsd:schema>
to validate this
XML file:
<?xml
version="1.0"?> <config> <dacEntity id="company.a"
name="Empresa A"
xmlns="urn:dac-entity-conf-2004-v1.0"> <entitySpecific> <entityDescription>zzzz</entityDescription> </entitySpecific> <dacConfig> <relations
basens="urn:dac-relation-conf-2004-v1.0"> <relation>relation.dep.a</relation> </relations> </dacConfig> </dacEntity> </config>
The problem
is:
I just want to
ensure that only the dacEntity is verified, so, in the xsd file i
set the
targetNamespace="urn:dac-entity-conf-2004-v1.0" and, in the xml file
relate dacEntity to
xmlns="urn:dac-entity-conf-2004-v1.0".
i'm geting this runtime
exception:
System.Xml.Schema.XmlSchemaException: XmlSchema error: Element
declaration for config is missing. XML Line 1,
Position 21.
My question
is:
with mono.net, i
can validate fragments of XML using xsd schemas or i must ensure
validation to a hole xml file?
Thaks!!
:)
|