Hello,
I have error when reading schema using XmlSchema. Read and then .Compile:
System.Xml.Sche ma.XmlSchemaExc eption: May not be nominated as the
{substitution
group affiliation} of any other declaration. An error occurred at , (11, 3).
Schema compile error:
System.Exceptio n: Schema error ---> System.Xml.Sche ma.XmlSchemaExc eption:
May no
t be nominated as the {substitution group affiliation} of any other
declaration.
An error occurred at , (11, 3).
--- End of inner exception stack trace ---
at XBRLMainClass.S chemaErrorHandl er(Object sender, ValidationEvent Args
vea) i
n c:\...\Main.cs: line 88
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption e,
XmlSe
verityType severity)
at
System.Xml.Sche ma.Compiler.Com pileSubstitutio nGroup(XmlSchem aSubstitutionG
roup substitutionGro up)
at System.Xml.Sche ma.Compiler.Com pileTo(SchemaIn fo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection collection,
XmlNam
eTable nameTable, SchemaNames schemaNames, ValidationEvent Handler
validationEven
tHandler, String targetNamespace , SchemaInfo schemaInfo, Boolean
compileContentM
odel, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchema.Co mpile(Validatio nEventHandler
validationEvent
Handler)
When I look at failing line I see:
<element id="pfsInc" name="Inc" type="xi:monIte mType"
substitutionGro up="xi:item" />
Element item is defined as
<element name="item" type="anySimple Type" abstract="true" />
What is wrong here?
Why error message doesn't specify exacly which file at error occured?
It doesn't matter if I specify abstract="true" or remove it.
Anybody can help to find the answer? As per W3 it should work. However
doesn't.
Code I use is simple:
fn=schemaFileNa meString;
FileStream fs=new FileStream(fn,F ileMode.Open);
XmlSchema xsd=null;
try {
xsd=XmlSchema.R ead(fs,new ValidationEvent Handler(SchemaE rrorHandler));
}
catch (Exception ex) {
Console.WriteLi ne("Schema read
exception:{0}{1 }",Environment. NewLine,ex.ToSt ring());
Console.WriteLi ne("Schema read failed.");
return;
}
finally {
fs.Close();
fs=null;
}
// compile schema
try {
xsd.Compile(new ValidationEvent Handler(SchemaE rrorHandler));
}
catch (Exception ex) {
Console.WriteLi ne("Schema compile error:{0}{1}",
Environment.New Line,
ex.ToString());
return;
}
Test schema file
<?xml version="1.0"?>
<schema targetNamespace ="instance" xmlns:xi="insta nce"
xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefa ult="qualified" >
<simpleType name="monT">
<restriction base="decimal"/>
</simpleType>
<simpleType name="shaT">
<restriction base="decimal">
<minInclusive value="0"/>
</restriction>
</simpleType>
<element name="itemAbs" type="anySimple Type" />
<!-- element name="item" type="anySimple Type"
substitutionGro up="xi:itemAbs " / -->
<element name="Inc" type="xi:monT" substitutionGro up="xi:itemAbs "/>
<element name="Dec" type="xi:shaT" />
</schema>
Anybody can point me in right direction? How can I define substitution group
in a way compatible with .Net?
Thanks!
Alex
I have error when reading schema using XmlSchema. Read and then .Compile:
System.Xml.Sche ma.XmlSchemaExc eption: May not be nominated as the
{substitution
group affiliation} of any other declaration. An error occurred at , (11, 3).
Schema compile error:
System.Exceptio n: Schema error ---> System.Xml.Sche ma.XmlSchemaExc eption:
May no
t be nominated as the {substitution group affiliation} of any other
declaration.
An error occurred at , (11, 3).
--- End of inner exception stack trace ---
at XBRLMainClass.S chemaErrorHandl er(Object sender, ValidationEvent Args
vea) i
n c:\...\Main.cs: line 88
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption e,
XmlSe
verityType severity)
at
System.Xml.Sche ma.Compiler.Com pileSubstitutio nGroup(XmlSchem aSubstitutionG
roup substitutionGro up)
at System.Xml.Sche ma.Compiler.Com pileTo(SchemaIn fo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection collection,
XmlNam
eTable nameTable, SchemaNames schemaNames, ValidationEvent Handler
validationEven
tHandler, String targetNamespace , SchemaInfo schemaInfo, Boolean
compileContentM
odel, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchema.Co mpile(Validatio nEventHandler
validationEvent
Handler)
When I look at failing line I see:
<element id="pfsInc" name="Inc" type="xi:monIte mType"
substitutionGro up="xi:item" />
Element item is defined as
<element name="item" type="anySimple Type" abstract="true" />
What is wrong here?
Why error message doesn't specify exacly which file at error occured?
It doesn't matter if I specify abstract="true" or remove it.
Anybody can help to find the answer? As per W3 it should work. However
doesn't.
Code I use is simple:
fn=schemaFileNa meString;
FileStream fs=new FileStream(fn,F ileMode.Open);
XmlSchema xsd=null;
try {
xsd=XmlSchema.R ead(fs,new ValidationEvent Handler(SchemaE rrorHandler));
}
catch (Exception ex) {
Console.WriteLi ne("Schema read
exception:{0}{1 }",Environment. NewLine,ex.ToSt ring());
Console.WriteLi ne("Schema read failed.");
return;
}
finally {
fs.Close();
fs=null;
}
// compile schema
try {
xsd.Compile(new ValidationEvent Handler(SchemaE rrorHandler));
}
catch (Exception ex) {
Console.WriteLi ne("Schema compile error:{0}{1}",
Environment.New Line,
ex.ToString());
return;
}
Test schema file
<?xml version="1.0"?>
<schema targetNamespace ="instance" xmlns:xi="insta nce"
xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefa ult="qualified" >
<simpleType name="monT">
<restriction base="decimal"/>
</simpleType>
<simpleType name="shaT">
<restriction base="decimal">
<minInclusive value="0"/>
</restriction>
</simpleType>
<element name="itemAbs" type="anySimple Type" />
<!-- element name="item" type="anySimple Type"
substitutionGro up="xi:itemAbs " / -->
<element name="Inc" type="xi:monT" substitutionGro up="xi:itemAbs "/>
<element name="Dec" type="xi:shaT" />
</schema>
Anybody can point me in right direction? How can I define substitution group
in a way compatible with .Net?
Thanks!
Alex
Comment