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 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, 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)> <!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>GeografÃa de Chile</name>
<acronym>GEO2005</acronym>
<allduration unit="months">5</allduration>
<description>Descripción del curso de GeografÃa de Chile... </description>
<designers>
<designer>Pedro Soto
</designer>
<designer>Juan Perez
</designer>
<designer>Manuel Gonzlez
</designer>
<designer>Herman Vega
</designer>
<designer>Denys Rodriguez
</designer>
</designers>
<resource type="link">http://www.ubiobio.cl/~gpoo/</resource>
<planprogression type="sequential">
<complete count="0" total="0" />
</planprogression>
<module id="1">
<name>Mod.1 Modulo 1</name>
<resource type="link">http://www.ubiobio.cl/~gpoo/</resource>
<moduleplanification>
<duration hour="1" min="2" />
<period min="3" max="4" unit="5" />
<evaluation>6</evaluation>
<interaction>
<team />
</interaction>
<groupwork hour="9" min="10" />
</moduleplanification>
<moduleprogression type="byoptions">
<weight>11</weight>
<complete count="13" total="14" />
</moduleprogression>
<notes>
<note type="public">
<name>Consideraciones basicas</name>
<date>16/08/2005</date>
<description>Relajarse.</description>
</note>
<note type="private">
<name>new note</name>
<date>18/10/2005</date>
<description>for test</description>
</note>
<note type="private">
<name>another test</name>
<date>19/10/2005</date>
<description>aaa</description>
</note>
</notes>
<activity id="1">
<name>Actividad 1</name>
<resource type="link">http://www.ubiobio.cl/~gpoo/</resource>
<role type="use" />
<planification>
<duration hour="2" min="40" />
<period min="3" max="4" unit="months" />
<evaluation>50</evaluation>
<interaction />
<jobs>10</jobs>
<datelimit>24/09/2005</datelimit>
</planification>
<progression>
<weight>1</weight>
<release>
<manual />
<automatic hour="0" min="5" sec="50" />
</release>
<validation>Cual es el nombre de la montana mas alta de Chile</validation>
</progression>
<advices>
<advice id="0">
<title>Google</title>
<description>Motor de busqueda muy poderoso</description>
<resource type="link">http://www.google.com/</resource>
</advice>
<advice id="1">
<title>Wikipedia.org</title>
<description>Enciclopedia libre</description>
<resource type="link">http://www.wikipedia.org/</resource>
</advice>
</advices>
<notes>
<note type="public">
<name>new note</name>
<date>04/10/2005</date>
<description>just a test</description>
</note>
<note type="private">
<name>another note</name>
<date>04/10/2005</date>
<description>test for private notes</description>
</note>
<note type="private">
<name>hello</name>
<date>04/10/2005</date>
<description>test2</description>
</note>
</notes>
</activity>
<activity id="2">
<name>Actividad 2</name>
<resource type="link">http://www.ubiobio.cl/~gpoo/</resource>
<role type="use" />
<planification>
<duration hour="2" min="40" />
<period min="3" max="4" unit="months" />
<evaluation>50</evaluation>
<interaction />
<jobs>10</jobs>
<datelimit>21/08/2005</datelimit>
</planification>
<progression>
<weight>1</weight>
<release>
<manual />
<automatic hour="0" min="5" sec="50" />
</release>
<validation>Cual es el nombre del rio mas largo de Chile</validation>
</progression>
<advices>
<advice id="0">
<title>Google</title>
<description>Motor de busqueda muy poderoso</description>
<resource type="link">http://www.google.com/</resource>
</advice>
<advice id="1">
<title>Wikipedia</title>
<description>Enciclopedia libre</description>
<resource type="link">http://www.wikipedia.org/</resource>
</advice>
</advices>
<notes>
<note type="private">
<name>note</name>
<date>04/10/2005</date>
<description>description for provate note</description>
</note>
</notes>
</activity>
<activity id="3">
<name>fdfdffd</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>19/10/2005</datelimit>
</planification>
<progression>
<weight>
</weight>
<release />
<validation>
</validation>
</progression>
<advices />
<notes />
</activity>
<activity id="4">
<name>sd</name>
<resource type="link" />
<role type="use" />
<planification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<jobs />
<datelimit />
</planification>
<progression>
<weight />
<release />
<validation />
</progression>
<advices />
<notes />
</activity>
</module>
<module id="2">
<name>Mod.2 Test</name>
<resource type="link">http://www.google.cl</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>testing</name>
<date>26/10/2005</date>
<description>dsddsfdfds</description>
</note>
</notes>
<module id="1">
<name>lala</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction>
<group />
</interaction>
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="sequential">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>dfdf</name>
<date>21/10/2005</date>
<description>fddf</description>
</note>
</notes>
<activity id="1">
<name>blah</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 />
<validation>
</validation>
</progression>
<advices />
<notes />
</activity>
<module id="1">
<name>sasaas</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction>
<team />
</interaction>
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="byoptions">
<weight>5</weight>
<complete count="3" total="4" />
</moduleprogression>
<notes />
<module id="1">
<name>Test Module</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes />
</module>
</module>
</module>
</module>
<module id="3">
<name>work</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction>
<team />
<group />
</interaction>
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>9</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>testing</name>
<date>19/10/2005</date>
<description>sasasas</description>
</note>
<note type="private">
<name>sdsdsd</name>
<date>19/10/2005</date>
<description>sdsdsd</description>
</note>
</notes>
<module id="1">
<name>subwork</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction>
<team />
</interaction>
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="byoptions">
<weight>
</weight>
<complete count="6" total="9" />
</moduleprogression>
<notes>
<note type="private">
<name>only test</name>
<date>19/10/2005</date>
<description>ssaa</description>
</note>
</notes>
<activity id="1">
<name>asdddssdsd</name>
<resource type="link">
</resource>
<role type="use" />
<planification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction>
<group />
</interaction>
<jobs>6</jobs>
<datelimit>31/10/2005</datelimit>
</planification>
<progression>
<weight>
</weight>
<release>
<manual />
</release>
<validation>
</validation>
</progression>
<advices>
<advice id="0">
<title>sdsd</title>
<description>dssd</description>
<resource type="link">http://localhost:12345/dsdssd</resource>
</advice>
<advice id="1">
<title>df</title>
<description>fddf</description>
<resource type="link">http://localhost:12345/fdfd</resource>
</advice>
</advices>
<notes>
</notes>
</activity>
</module>
</module>
<module id="4">
<name>do</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>testing only</name>
<date>20/10/2005</date>
<description>sa</description>
</note>
</notes>
</module>
<module id="5">
<name>dsfdssd</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
</module>
<module id="6">
<name>rreerree</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
</module>
<module id="7">
<name>retretfgsdfg</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
</module>
<module id="8">
<name>sgsgdsdf</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>dfdf</name>
<date>21/10/2005</date>
<description>dfdf</description>
</note>
</notes>
<activity id="1">
<name>dssd</name>
<resource type="link" />
<role type="use" />
<planification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<jobs />
<datelimit />
</planification>
<progression>
<weight />
<release />
<validation />
</progression>
<advices />
<notes />
</activity>
</module>
<module id="9">
<name>!! ¿prúébá dé ácéntós y Ãñ? ¡¡</name>
<resource type="link">http://www.google.com/search?q=UTF-8</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>Acentos</name>
<date>27/10/2005</date>
<description>Prúébá dé téxtó cón múchós ácéntós y ÃÃÃññññ's y ?¿ !!!¡¡¡¡ y ke más se usa?</description>
</note>
</notes>
<module id="1">
<name>nombre del testk</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes />
</module>
</module>
<module id="10">
<name>test deep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeeep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeeeep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeeeeep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeeeeeep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeeeeeeep</name>
<resource type="link" />
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation />
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight />
<complete count="0" total="0" />
</moduleprogression>
<notes />
<module id="1">
<name>deeeeeeeeep</name>
<resource type="link">
</resource>
<moduleplanification>
<duration hour="0" min="0" />
<period min="0" max="0" unit="months" />
<evaluation>
</evaluation>
<interaction />
<groupwork hour="0" min="0" />
</moduleplanification>
<moduleprogression type="bymodules">
<weight>
</weight>
<complete count="0" total="0" />
</moduleprogression>
<notes>
<note type="private">
<name>show scroll</name>
<date>27/10/2005</date>
<description>aaa</description>
</note>
</notes>
</module>
</module>
</module>
</module>
</module>
</module>
</module>
</module>
</plan>
activities.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
