Click here to Skip to main content
14,834,049 members
Home / Discussions / XML / XSL


QuestionHelp to write Xquery Pin
Neno9930-Apr-11 3:37
MemberNeno9930-Apr-11 3:37 
AnswerRe: Help to write Xquery Pin
jschell30-Apr-11 12:57
Memberjschell30-Apr-11 12:57 
GeneralRe: Help to write Xquery Pin
Neno993-May-11 16:07
MemberNeno993-May-11 16:07 
GeneralRe: Help to write Xquery Pin
Richard MacCutchan3-May-11 21:58
mveRichard MacCutchan3-May-11 21:58 
GeneralRe: Help to write Xquery Pin
jschell4-May-11 8:47
Memberjschell4-May-11 8:47 
QuestionHow to bind the data into a class object from a list. Pin
Rocky2329-Apr-11 0:57
MemberRocky2329-Apr-11 0:57 
AnswerRe: How to bind the data into a class object from a list. Pin
jschell29-Apr-11 9:47
Memberjschell29-Apr-11 9:47 
QuestionXML Search Pin
DJ24526-Apr-11 20:49
MemberDJ24526-Apr-11 20:49 
AnswerRe: XML Search Pin
GregStevens6-Jul-11 15:43
MemberGregStevens6-Jul-11 15:43 
QuestionXpath syntax. Pin
Mel Padden4-Apr-11 22:34
MemberMel Padden4-Apr-11 22:34 
AnswerRe: Xpath syntax. Pin
Tarun.K.S4-Apr-11 23:40
MemberTarun.K.S4-Apr-11 23:40 
GeneralRe: Xpath syntax. Pin
Mel Padden5-Apr-11 0:06
MemberMel Padden5-Apr-11 0:06 
QuestionHelp to make condition in xsd file Pin
MrKBA30-Mar-11 22:41
MemberMrKBA30-Mar-11 22:41 
AnswerRe: Help to make condition in xsd file Pin
RugbyLeague19-Apr-11 2:26
MemberRugbyLeague19-Apr-11 2:26 
Questionattribute restriction [modified] [Solved] Pin
V.24-Mar-11 22:40
professionalV.24-Mar-11 22:40 
I wrote a small .Net app that validates an XML with an XSD.
It looks like it is working, until I did the following below.

the XML is validated although the attribute is restricted to 8 chars.
What could I be doing wrong?

many thanks.

like this:
public static void Validate(string xml_file, string xsd_file, string xmlnamespace){
    schemaexception = null;
    validationexception = null;
    XmlReader reader  = null;
    XmlReaderSettings xmlreadersettings = new XmlReaderSettings();
    XmlSchemaSet myschema = new XmlSchemaSet();
        xmlreadersettings.Schemas.Add(xmlnamespace, xsd_file);
        xmlreadersettings.ValidationType = ValidationType.Schema;
        xmlreadersettings.ValidationEventHandler += new ValidationEventHandler(xmlreadersettings_ValidationEventHandler);
        reader = XmlReader.Create(xml_file, xmlreadersettings);
    }                                               //end try
    catch (XmlException XmlExp){
        schemaexception = XmlExp;
    }                                               //end catch
    catch(XmlSchemaException XmlSchExp){
        schemaexception = XmlSchExp;
    }                                               //end catch
    catch(Exception GenExp){
        schemaexception = GenExp;
    }                                               //end catch
    }                                               //end finally


[EDIT]I found an online tool dat also validates the xml against the xsd and that seems to work. it even says what the exact error is. I'll have to have a look at the .Net code. If anyone has a good article about it, let me know. (I'll also, of course, search for myself)[/EDIT]

<MyCode value="abcdefSSSgh"/>

<xs:element name="MyCode" minOccurs="1">
    <xs:attribute name="value" use="required">
        <xs:restriction base="xs:string">
          <xs:length value="8"/>

.Net code
public static Exception Validate(string xml_file, string xsd_file, string xmlnamespace){
    Exception xmlexception = null;
    XmlReader reader  = null;
    XmlSchemaSet myschema = new XmlSchemaSet();
        reader = XmlReader.Create(xml_file);
        myschema.Add(xmlnamespace, xsd_file);
        while (reader.Read());
    }                                               //end try
    catch (XmlException XmlExp){
        xmlexception = XmlExp;
    }                                               //end catch
    catch(XmlSchemaException XmlSchExp){
        xmlexception = XmlSchExp;
    }                                               //end catch
    catch(Exception GenExp){
        xmlexception = GenExp;
    }                                               //end catch
    return xmlexception;

modified on Friday, March 25, 2011 6:07 AM

QuestionVisual Studio's XSD vs Liquid Technologies Code Generator Pin
Ger Hayden16-Mar-11 4:40
MemberGer Hayden16-Mar-11 4:40 
Questionusing search web service Pin
ekaup11-Mar-11 23:36
Memberekaup11-Mar-11 23:36 
AnswerRe: using search web service Pin
jschell13-Mar-11 10:16
Memberjschell13-Mar-11 10:16 
GeneralRe: using search web service Pin
ekaup13-Mar-11 12:22
Memberekaup13-Mar-11 12:22 
QuestionHow limitate the attribute of the root to it? Pin
Pierre besquent24-Feb-11 22:06
MemberPierre besquent24-Feb-11 22:06 
AnswerRe: How limitate the attribute of the root to it? Pin
dasblinkenlight9-Mar-11 2:20
Memberdasblinkenlight9-Mar-11 2:20 
QuestionIs Serialization worth it? Pin
Ger Hayden21-Feb-11 23:47
MemberGer Hayden21-Feb-11 23:47 
Questiongenerate xml based on schema. Pin
Ramkumar_S16-Feb-11 15:33
MemberRamkumar_S16-Feb-11 15:33 
AnswerRe: generate xml based on schema. Pin
Ger Hayden22-Feb-11 0:04
MemberGer Hayden22-Feb-11 0:04 
QuestionCustomizing RSS Feed - XSL to display rss your way. Pin
Sparx200914-Feb-11 2:36
MemberSparx200914-Feb-11 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.