XML writing error

  • Thread starter Abdessamad Belangour
  • Start date
A

Abdessamad Belangour

Hi all,
I have developped an application that generate XML documents.
At most time it works fine, but sometimes (when the size of data to export
is big) i got the error message :
<< The StartElement token in the Epilog state will generate a nonvalid XML
document :
at System.XML.XMLTextWriter.AutoComplete(Token token)
at System.XML.XMLTextWriter.WriteStartElement(String prefix, String
localName,String ns)
at System.XML.XMLTextWriter.WriteStartElement(String prefix, String
localName,String ns) at.....etc.>>
I have reviewed well formedness of my XML instructions but i have found no
error in them.
Please, give me any idea to track and solve the problem.
Thanks in advance.
 
J

Jon Skeet [C# MVP]

Abdessamad Belangour said:
I have developped an application that generate XML documents.
At most time it works fine, but sometimes (when the size of data to export
is big) i got the error message :
<< The StartElement token in the Epilog state will generate a nonvalid XML
document :
at System.XML.XMLTextWriter.AutoComplete(Token token)
at System.XML.XMLTextWriter.WriteStartElement(String prefix, String
localName,String ns)
at System.XML.XMLTextWriter.WriteStartElement(String prefix, String
localName,String ns) at.....etc.>>
I have reviewed well formedness of my XML instructions but i have found no
error in them.
Please, give me any idea to track and solve the problem.

The stack trace should show where in your code it's complaining -
please post that section of code, and what the data is like at the
time.
 
A

Abdessamad Belangour

Jon,
The stack trace indicate that the problem is in the first line of the method
below, but the problem could be outside. Anyway all the methods calls in
this method are safe.

private void serializeProperty(PropertyInfo pr)
{
writer.WriteStartElement("UML:Attribute");

writer.WriteAttributeString("xmi.id",IdsGen.generatePropertyId(pr).ToString(
));
writer.WriteAttributeString("name",pr.Name);
writer.WriteAttributeString("visibility","public");
writer.WriteAttributeString("isSpecification","false");
writer.WriteAttributeString("ownerScope","instance");
//streotype of property accessiblility
if ((pr.CanRead)&&(pr.CanWrite)) serializeRefToStereotype("ReadWrite");
else
i f (pr.CanRead) serializeRefToStereotype("Read");
else serializeRefToStereotype("Write");

//property type
writer.WriteStartElement("UML:StructuralFeature.type");
writeTypeIDREF(pr.PropertyType);//id reference
writer.WriteEndElement();
writer.WriteEndElement();
}

Thanks !
 
J

Jon Skeet [C# MVP]

Abdessamad Belangour said:
The stack trace indicate that the problem is in the first line of the method
below, but the problem could be outside. Anyway all the methods calls in
this method are safe.

private void serializeProperty(PropertyInfo pr)
{
writer.WriteStartElement("UML:Attribute");

If the exception is occurring here, then it should occur every time.
Have you tried stepping through to see whether it really is every time?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top