Discussion:
MSXML SOM Problems
(too old to reply)
Justin
2005-07-22 17:14:02 UTC
Permalink
I am attempting to use the SOM interface to access information in a schema
(XSD) but i am not getting the correct information back. I am attempting to
get the min and max occurs properties for elements in my schema but no matter
what element i access they all return 1 for min occurs and 1 for max occurs.
This is not correct because several elements in the schema have a min occurs
of 0 and max occurs of unbounded. Any help would be greatly appreciated.


Info:

Office 2003
VBA 6.3
MSXML 5.0
Marvin Smit
2005-07-25 13:07:15 UTC
Permalink
Hi,

Are u sure the schema is compiled before you try to access this
information?

Hope this helps,

Marvin Smit

On Fri, 22 Jul 2005 10:14:02 -0700, Justin
Post by Justin
I am attempting to use the SOM interface to access information in a schema
(XSD) but i am not getting the correct information back. I am attempting to
get the min and max occurs properties for elements in my schema but no matter
what element i access they all return 1 for min occurs and 1 for max occurs.
This is not correct because several elements in the schema have a min occurs
of 0 and max occurs of unbounded. Any help would be greatly appreciated.
Office 2003
VBA 6.3
MSXML 5.0
Justin
2005-07-25 21:07:03 UTC
Permalink
Marvin

Thank you for replying. I'm not totally sure what you mean by compiled could
you be more specific.

Justin
Post by Marvin Smit
Hi,
Are u sure the schema is compiled before you try to access this
information?
Hope this helps,
Marvin Smit
On Fri, 22 Jul 2005 10:14:02 -0700, Justin
Post by Justin
I am attempting to use the SOM interface to access information in a schema
(XSD) but i am not getting the correct information back. I am attempting to
get the min and max occurs properties for elements in my schema but no matter
what element i access they all return 1 for min occurs and 1 for max occurs.
This is not correct because several elements in the schema have a min occurs
of 0 and max occurs of unbounded. Any help would be greatly appreciated.
Office 2003
VBA 6.3
MSXML 5.0
Marvin Smit
2005-07-26 11:29:16 UTC
Permalink
Hi Justin,

although this is C# code it should show you the idea of reading facet
info from an element.

static void Main(string[] args)
{
XmlReader xReader = null;

if (args.Length < 1)
{
Console.WriteLine("Usage: XSDDump.exe
{schema.xsd}");
return;
}

try
{
xReader = new XmlTextReader(args[0]);
}
catch (Exception ex)
{
Console.WriteLine("XSD Failed to
load\r\n{0}", ex.StackTrace);
}

XmlSchema xSchema = XmlSchema.Read( xReader ,
null );

xSchema.Compile( null );

DumpSchema( xSchema );
}

static void DumpSchema( XmlSchema xSchema )
{
foreach (XmlSchemaObject xElem in
xSchema.Elements.Values)
{
XmlSchemaElement xsElem = xElem as
XmlSchemaElement;
Console.WriteLine(String.Format(
"Element : {{0}}:{1}", xSchema.TargetNamespace, xsElem.Name));
Console.WriteLine(String.Format(
"\tminOccurs = {0}", xsElem.MinOccurs.ToString()));
Console.WriteLine(String.Format(
"\tmaxOccurs = {0}", xsElem.MaxOccurs.ToString()));
}
}

Hope this helps,

Marvin Smit.


On Mon, 25 Jul 2005 14:07:03 -0700, Justin
Post by Marvin Smit
Marvin
Thank you for replying. I'm not totally sure what you mean by compiled could
you be more specific.
Justin
Post by Marvin Smit
Hi,
Are u sure the schema is compiled before you try to access this
information?
Hope this helps,
Marvin Smit
On Fri, 22 Jul 2005 10:14:02 -0700, Justin
Post by Justin
I am attempting to use the SOM interface to access information in a schema
(XSD) but i am not getting the correct information back. I am attempting to
get the min and max occurs properties for elements in my schema but no matter
what element i access they all return 1 for min occurs and 1 for max occurs.
This is not correct because several elements in the schema have a min occurs
of 0 and max occurs of unbounded. Any help would be greatly appreciated.
Office 2003
VBA 6.3
MSXML 5.0
Loading...