Hi all,
I wrote some generator of classes from XSD files but encountred unexpected (for me) values in parsed DOM.
First I load XSD with XmlSchema.Read() method, then iterate through XmlSchemaElements. I have a function
IsComplex() which return bool value if it has simple content (e.g. type string, int,...) or complex one (sequence,
choice, ..). This function looks like this:
bool IsComplex(XmlSchemaElement el) {
if (el.SchemaType is XmlSchemaComplexType) {
XmlSchemaComplexType t = (XmlSchemaComplexType)el.SchemaType;
if (t.ContentModel is XmlSchemaSimpleContent)
return false;
else
return true;
}
else
return false;
}
but when I use definition of type within XSD, SchemaType property of element returns null. I would expect here
instance of XmlSchemaComplexType. However SchemaTypeName is not null and contains correct value
(PackageList for example bellow).
Is it correct behaviour ? Is there better approach how to recognize content of schema element ?
Here's sample of XSD:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://test.shipments" targetNamespace="http://test.shipments" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shipments">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="shipment">
<xs:complexType>
<xs:sequence>
<xs:element name="shipment_reference" type="xs:string" />
<xs:element name="packages" type="PackageList" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="PackageList">
<xs:sequence>
<xs:element name="package_reference" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Thanks for any help,
eXavier 2 2613
You must compile your schema using XmlSchema.Compile and then access the ElementType property to obtain an instance of the XmlSchemaType corresponding to the type in the schema.
"eXavier" <fh**@centrum.cz> wrote in message news:uA**************@TK2MSFTNGP14.phx.gbl...
Hi all,
I wrote some generator of classes from XSD files but encountred unexpected (for me) values in parsed DOM.
First I load XSD with XmlSchema.Read() method, then iterate through XmlSchemaElements. I have a function
IsComplex() which return bool value if it has simple content (e.g. type string, int,...) or complex one (sequence,
choice, ..). This function looks like this:
bool IsComplex(XmlSchemaElement el) {
if (el.SchemaType is XmlSchemaComplexType) {
XmlSchemaComplexType t = (XmlSchemaComplexType)el.SchemaType;
if (t.ContentModel is XmlSchemaSimpleContent)
return false;
else
return true;
}
else
return false;
}
but when I use definition of type within XSD, SchemaType property of element returns null. I would expect here
instance of XmlSchemaComplexType. However SchemaTypeName is not null and contains correct value
(PackageList for example bellow).
Is it correct behaviour ? Is there better approach how to recognize content of schema element ?
Here's sample of XSD:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://test.shipments" targetNamespace="http://test.shipments" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shipments">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="shipment">
<xs:complexType>
<xs:sequence>
<xs:element name="shipment_reference" type="xs:string" />
<xs:element name="packages" type="PackageList" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="PackageList">
<xs:sequence>
<xs:element name="package_reference" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Thanks for any help,
eXavier
Thanks a lot, it works as I need.
However, MSDN class library is poor documentation for using SOM, is there some good source of information on working with SOM ?
I would rather avoid this try-fail approach next time.
eXavier
"Zafar Abbas [MSFT]" <za****@microsoft.com> wrote in message news:%2******************@TK2MSFTNGP14.phx.gbl...
You must compile your schema using XmlSchema.Compile and then access the ElementType property to obtain an instance of the XmlSchemaType corresponding to the type in the schema.
"eXavier" <fh**@centrum.cz> wrote in message news:uA**************@TK2MSFTNGP14.phx.gbl...
Hi all,
I wrote some generator of classes from XSD files but encountred unexpected (for me) values in parsed DOM.
First I load XSD with XmlSchema.Read() method, then iterate through XmlSchemaElements. I have a function
IsComplex() which return bool value if it has simple content (e.g. type string, int,...) or complex one (sequence,
choice, ..). This function looks like this:
bool IsComplex(XmlSchemaElement el) {
if (el.SchemaType is XmlSchemaComplexType) {
XmlSchemaComplexType t = (XmlSchemaComplexType)el.SchemaType;
if (t.ContentModel is XmlSchemaSimpleContent)
return false;
else
return true;
}
else
return false;
}
but when I use definition of type within XSD, SchemaType property of element returns null. I would expect here
instance of XmlSchemaComplexType. However SchemaTypeName is not null and contains correct value
(PackageList for example bellow).
Is it correct behaviour ? Is there better approach how to recognize content of schema element ?
Here's sample of XSD:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://test.shipments" targetNamespace="http://test.shipments" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shipments">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="shipment">
<xs:complexType>
<xs:sequence>
<xs:element name="shipment_reference" type="xs:string" />
<xs:element name="packages" type="PackageList" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="PackageList">
<xs:sequence>
<xs:element name="package_reference" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Thanks for any help,
eXavier This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: eXavier |
last post by:
Hi all,
I wrote some generator of classes from XSD files but encountred unexpected (for me) values in parsed DOM.
First I load XSD with XmlSchema.Read() method, then iterate through...
|
by: Rein Petersen |
last post by:
Hi Folks,
I'm reading a schema using SOM (System.Xml.Schema) and there are namespaced
attributes that I need to access but I'm having problems with the
UnhandledAttributes property - that is is...
|
by: Rein Petersen |
last post by:
Somebody please tell me what is the matter with the
System.Xml.Schema.XmlSchemaElement.UnhandledAttributes property.
I don't seem to be able to access no matter how I try...
Rein
|
by: Christian Lammel |
last post by:
OK, repost:
> I implemented a schema helper function GetDeclaration (similar to MSXML),
> that finds a XmlSchemaElement for a given XmlElement, using a
> XmlSchemaCollection. There is one kind...
|
by: ezra epstein |
last post by:
Aother head banger for me.
Below is a complete example of the code
Using Postgres 7.4,
the function "test" gets this: psql:temp3.sql:10: ERROR: syntax error
at or near "%" at character 135...
|
by: Sam Vanhoutte |
last post by:
Hello,
I am generating an XML schema for the use in Biztalk 2004. Everything
works, except for one simple thing.
I cannot add XmlSchemaElements to a XmlSchemaComplexType. This is necessary...
|
by: Josh |
last post by:
Is there anyway to get the correct XmlSchemaElement from an XSD that
corresponds to an element within an Xml Document Instance?
I want to automatically generate a UI for an Xml Instance based...
|
by: Lyle Fairfield |
last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp
"If the value of the variant argument is Null, the Nz function returns
the number zero or a...
|
by: Henning M |
last post by:
Hej All
Im relativ new to VB.net and im trying to collect som device information
using cfgmgr32.dll
I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias...
|
by: Francois Grieu |
last post by:
When running the following code under MinGW, I get
realloc(p,0) returned NULL
Is that a non-conformance?
TIA,
Francois Grieu
#include <stdio.h>
#include <stdlib.h>
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |