Hi All... I need to validate an Xml content and I have two ways:
* Using DTD file.
* Using XSD schema file.
The problem is that i have a DTD file that it's ok, work fine with
xmllint validation program. but my implementation with DTD Validation
don't work with mono. I decide to work with XSD validation schema and
work fine for me. Now i can validate a xml against XSD schema file
very well with mono.
But here it's the new problem... when i generate a XSD schema file
from XML using xsd.exe this generate a wrong XSD Schema file.
Now the 2 ways... (1) how i can generate a valid XSD schema file from
Xml (not manual) or (2) how i can validate a Xml using valid DTD file?
I attached the source files that I'm still working
The error using DTD validation:
$ mono -V
Mono JIT compiler version 1.1.8.2, (C) 2002-2005 Novell, Inc and
Contributors. www.mono-project.com
TLS: __thread
GC: Included Boehm (with typed GC)
SIGSEGV : normal
Globalization: norma
$ mcs --version
Mono C# compiler version 1.1.8.0
$ mono ValidateXml.exe DTD activities.dtd activities.xml
Unhandled Exception: System.Xml.XmlException: Unexpected declaration
markup was found. file:///home/hvega/ticedu/xml/TestXml/activities.dtd
Line 2, position 3.
Regards
--
,''`. Herman Vega Jara <[EMAIL PROTECTED]>
: :' : Ing. ejec. Comp. e Inf. at UBB rlz!
`. `' http://gbtcr.chileforge.cl
`-
<!-- top-level element --> <!ELEMENT activityfile (plan)> <!-- a single plan has a set of modules --> <!ELEMENT plan (name,acronym,allduration,description,designers,resource,planprogression,module+)> <!ATTLIST plan id CDATA #REQUIRED> <!ELEMENT name (#PCDATA)> <!ELEMENT acronym (#PCDATA)> <!ELEMENT description (#PCDATA)> <!ELEMENT designers (designer*)> <!ELEMENT designer (#PCDATA)> <!ELEMENT allduration (#PCDATA)> <!ATTLIST allduration unit CDATA "months"> <!-- --> <!ELEMENT module (name, resource, moduleplanification, moduleprogression, advices, notes,(activity|module)*)> <!ATTLIST module id CDATA #REQUIRED> <!-- A resource is provided by link or external store --> <!ELEMENT resource (#PCDATA)> <!ATTLIST resource type (link|external) "link"> <!ELEMENT notes (note*)> <!ELEMENT note (name,date,description)> <!ATTLIST note type (public|private) #REQUIRED> <!ELEMENT date (#PCDATA)> <!-- --> <!-- A single activity (a set of elements) --> <!ELEMENT activity (name,resource,role,planification,progression,advices,notes)> <!ATTLIST activity id CDATA #REQUIRED> <!-- The type of role (use|consult|produce|execute) --> <!ELEMENT role EMPTY> <!ATTLIST role type (none|use|consult|produce|execute) "none"> <!ELEMENT planification (duration,period,evaluation,interaction,jobs,datelimit)> <!-- duration of the whole activity --> <!ELEMENT duration EMPTY> <!ATTLIST duration hour CDATA "0" min CDATA "0"> <!-- Planification of time between start and finish the activity --> <!ELEMENT period EMPTY> <!ATTLIST period min CDATA "0" max CDATA "0" unit CDATA "months"> <!-- Percentage of advance --> <!ELEMENT evaluation (#PCDATA)> <!-- Kind of interaction --> <!ELEMENT interaction (team?,group?)> <!ELEMENT team EMPTY> <!ELEMENT group EMPTY> <!-- # of jobs to be sent --> <!ELEMENT jobs (#PCDATA)> <!-- Last date to get the activity done --> <!ELEMENT datelimit (#PCDATA)> <!ELEMENT planprogression (complete)> <!ATTLIST planprogression type (bymodules|sequential|parallel|byoptions) "bymodules"> <!ELEMENT moduleplanification (duration,period,evaluation,interaction ,groupwork)> <!ELEMENT groupwork EMPTY> <!ATTLIST groupwork hour CDATA "0" min CDATA "0"> <!ELEMENT moduleprogression (weight,complete, validation)> <!ATTLIST moduleprogression type (bymodules|sequential|parallel|byoptions) "bymodules"> <!ELEMENT complete EMPTY> <!ATTLIST complete count CDATA "0" total CDATA "0" > <!ELEMENT progression (weight,release,validation)> <!ELEMENT weight (#PCDATA)> <!ELEMENT release (manual?,automatic?)> <!ELEMENT manual EMPTY> <!ELEMENT automatic EMPTY> <!ATTLIST automatic hour CDATA "0" min CDATA "0" sec CDATA "50"> <!ELEMENT validation (#PCDATA)> <!ELEMENT advices (advice*)> <!ELEMENT advice (title,description,resource)> <!ATTLIST advice id CDATA #REQUIRED> <!ELEMENT title (#PCDATA)>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE activityfile SYSTEM "activities.dtd"[]>
<plan id="1">
<name>Plan Name</name>
<acronym></acronym>
<allduration unit="months"> </allduration>
<description> </description>
<designers>
</designers>
<resource type="link"> </resource>
<planprogression type="sequential">
<complete count="0" total="0" />
</planprogression>
<module id="1">
<name>Mod.1 Name Modulo 1</name>
<resource type="link"> </resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="0" />
<evaluation> </evaluation>
<interaction>
<team />
</interaction>
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight> </weight>
<complete count="0" total="0" />
<validation> </validation>
</moduleprogression>
<advices>
</advices>
<notes>
</notes>
<activity id="1">
<name>Activity 1</name>
<resource type="link"> </resource>
<role type="use" />
<planification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation> </evaluation>
<interaction />
<jobs> </jobs>
<datelimit> </datelimit>
</planification>
<progression>
<weight> </weight>
<release>
<manual />
<automatic hour="0" min="0" sec="0" />
</release>
<validation> </validation>
</progression>
<advices>
</advices>
<notes>
</notes>
</activity>
</module>
</plan>
activity.xsd
Description: Binary data
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace ValidationSample
{
class Sample
{
public static void Main (string [] args)
{
XmlTextReader tr = new XmlTextReader (args[2]);
XmlValidatingReader vr = new XmlValidatingReader (tr);
if (args[0] == "DTD")
// for DTD validation
vr.ValidationType = ValidationType.DTD;
else if (args[0] == "XSD")
// form schema XSD validation
vr.ValidationType = ValidationType.Schema;
vr.Schemas.Add(string.Empty, args[1]);
vr.ValidationEventHandler +=
new ValidationEventHandler (ValidationHandler);
while (vr.Read ());
Console.WriteLine ("End Validation");
}
public static void ValidationHandler (object sender,
ValidationEventArgs args)
{
Console.WriteLine ("***Validation error");
Console.WriteLine ("\tSeverity:{0}", args.Severity);
Console.WriteLine ("\tMessage :{0}", args.Message);
}
}
}
_______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
