Home » Microsoft Technologies

get_nodeTypedValue equivalent for XSD?

Hi all,

I know the MSXML get_nodeTypedValue method is only supported with XDR schemas and does not work with XSD schemas. However we use this extensively in our applicaton to get typed values from input XML based on the corresponding type definition in the XML's schema. Is there any equivalent to this when using XSD in MSXML6? We are forced to having to convert to using XSD schemas as XDR schemas are no longer supported in MSXML6 :(

FYI - The background to this is that for a lot of our customers when Windows update installs MSXML6 or a patch for it, it is unregistering MSXML3 and breaking our application. So we having to convert our codebase to MSXML6 to get around this.

Thanks in advance,

    Charles Gamble.




2 Answers Found


Answer 1

There is no equivalent  API for get_nodeTypedValue in MSXML6. You need to get the node value as BSTR through get_nodeValue, and then covert to corresponding typed value by your own.


Installing msxml6  should not unregistering MSXML3. What platform (OS, service pack, etc) did you see such behavior? MSXML3 and MSXML6 are both in-band Windows components in XP SP3, Vista and later OSes. See http://blogs.msdn.com/b/xmlteam/archive/2010/07/02/msxml6-is-now-in-band-msi-setup-headaches-should-now-almost-be-gone.aspx


Answer 2

Thanks for the reply.

If I use get_nodeValue how can I get the actual type  for the node as defined in the applied XML schema?





I'm doing a contract first development, where we develop our "interface" as XSD schemas in Biztalk 2006/R2 (in Visual Studio 2005).

Several years ago, I did this at a client that was using .asmx web service.  Now I want to do the same with WCF.   What I'm missing is that the XSD utility never seemed to be updated to handle the new xmlserialization attributes needed by WCF.

I have created a schema as an agreed upon interface between our company and an external company. I am now creating a WCF C# web service to handle the interface.

I ran the XSD utility and it created a C# class. The schema was built in BizTalk, and references other schemas, so all-in-all there are over 15 classes being generated.

I put [DataContract} attribute in front of each of the classes. Do I have to put the [DataMember] attribute on every single property?
When I generate a test client program, the proxy does not have any code for any of these 15 classes.

I can manually add them, but I anticipate that the .xsd will change frequently over the next few weeks, and each time it changes, we must regen the C# classes. 

I'm also exploring XSDObjectGenerator.exe (seems to have a problem handling the BizTalk imports of one schema to another), and also looking at http://wscfblue.codeplex.com, but waiting on some answers there.

Neal Walters


I'm trying to use the XSD task to convert a schema file to a C# file.

In my csproj file I have the following:

<UsingTaskTaskName="XSD"AssemblyName="Microsoft.Build.CppTasks.Common, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/><TargetName="BeforeBuild"><XSDSources="MySchema.xsd"GenerateFromSchema="classes"Language="CS"></XSD></Target>

When I try to build the project I get the following error reported:

error MSB4018: The "XSD" task failed unexpectedly.
error MSB4018: Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: xsd.exe unexpectedly not a rooted path
error MSB4018: at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Object[] args)
error MSB4018: at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInternalRooted(String value)
error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.TrackerExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)
error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)
error MSB4018: at Microsoft.Build.Utilities.ToolTask.Execute()
error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)




Any suggestion as to what I've got wrong (I can't find a working example of using XSD task)?



Hi all,

I have a schema (say Order) which imports 2 schemas which also imports other schemas and so on - each of the imported schemas has its own namespace. This seemed to be a good idea in order to reuse schemas over multiple documents. When I generate an instance of the Order schema all the referenced schema namespaces are not used, only the default namespace of the Order schema - I think this is because I am referencing all the schemas as complex types - I need to do this because the names of the elements will be different depending on the context in which they are used. 


<Order xmlns="http://Order">

<order-header> --> this is imported with a ns of http://order-header but is not expected in the xml instance.




What I want to be able to do is create a library of code to give to my developers to use in web services in order for BizTalk to pass these messages types (e.g. Order) to services that these guys expose.

I have successfully used xsd.exe (and Xsd2Code) to generate these classes, however these tools generate the partial classes for the imported schemas (e.g order-header) with the namespaces therefore when ever BizTalk passes a message the web service cannot deserialize the message because it doesn't sent the order-address element with a different namespace. 

Is there a way when generating code from XSD's to exclude the namespaces of the imported schemas so it matches what the (Order) schema expects?


Any help would be appreciated...




How can I use XSD.exe to generate a XSD from a "Set" of XML Instance documents. It seems to take only one XML document at a time.






Hi all.
I have found a weird thing with .NET XML (de)serialization and thought i'd check it here before i submit a bug report.

It seems like .NET deserializes tags with type xsd:normalizedString improperly:
As I interpret it, these sections in the xsd spec supports the idea that spaces should be preserved when reading a normalizedstring tag: White space normalization during validation and whiteSpace facet specification and normalizedString

According to the spec, normalizedstring should replace ordinary whitespace with single spaces (whitespace facet = replace), it should not however strip any leading/trailing spaces as xsd:token does (whitespace facet = collapse)

I have done a test case, defining an xsd file and generating a class through the xsd.exe tool.
Although have only tried this on vs2008 .net3.5 so far, the code example should not be 3.5 specific as long as the signature of the framework calls haven't changed between versions.

The initial xsd is:


I then ran xsd /classes /n:TestNormalizedString <xsdfile>, yielding this .cs file (minus some comment lines):

namespace TestNormalizedString {

    using System.Xml.Serialization;




    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]




    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://tempuri.org/nstringtest.xsd")]

    [System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/nstringtest.xsd", IsNullable=false)]

    publicpartialclass TestNormalizedString {


        privatestring theStringField;




        publicstring TheString {

            get {



            set {

                this.theStringField = value;





And finally running it through a small test program:

using System;

using System.IO;

using System.Xml.Serialization;

namespace TestNormalizedString


    class Program


        staticvoid Main(string[] args)


            XmlSerializer xSer = new XmlSerializer(typeof(TestNormalizedString));

            // Prepare an object

            TestNormalizedString tnsObj = new TestNormalizedString();

            tnsObj.TheString = " "; // Whitespace 0x20 (space)

            Console.WriteLine("Content of 'TheString' member = [{0}]", tnsObj.TheString);

            // Serialize it

            StringWriter sWrt = new StringWriter();

            xSer.Serialize(sWrt, tnsObj);

            Console.WriteLine("Serialized object: {0}", sWrt.ToString());

            // Now, deserialize it again

            tnsObj = xSer.Deserialize(new StringReader(sWrt.ToString())) as TestNormalizedString;

            Console.WriteLine("Content of 'TheString' member = [{0}]", tnsObj.TheString); // Aand it's gone!




The result is that the space is not removed when serializing but removed upon deserialization. Isn't this a violation of the xsd spec?

So, in short the question is: Do you agree that this is a bug or do you disagree with my interpretation of the spec?


Currently, I'm a little confused. On a regular basis, I am using XSD files and xsd.exe to create strongly typed C# classes for XML data. Using Visual Studio 2005 and 2008, there was an editor for XSD files, in which I could create new elements, attributes and define relationships between elements.

Now, using Visual Studio 2010, I find this new flashy thing called XSD Designer, but it seems to be all read only? I can view and visualize my XSD schema real nice, but I haven't found a single way of changing something withing the XSD, without using the XML Editor directly. The VS2010 documentation seems to say the same thing, i.e. "use the XML Editor to alter the schema definition."

Am I missing something, or is this actually functionality that was removed with Visual Studio 2010?

Best regards,

Using xsd.exe tool, how to generate reusable base types when generating from multiple xsd's with same includes?
I am using MS Access 2007 with the following code in a form:

Dim ecObjects As MSXML2.IXMLDOMParseError2
Dim domObject As MSXML2.DOMDocument60
Dim ecObject As MSXML2.IXMLDOMParseError2

Set ecObjects = domObject.validate
For Each ecObject In ecObjects.allErrors
    Set lstItem = Me.lvwValidation.ListItems.Add(, , ecObject.line)
    With lstItem
        .ListSubItems.Add , , ecObject.reason
    End With
Next ecObject

The xml in the domObject is:

<User xmlns="test:test" FirstName="John" LastName="Smith">
    <Account Account="12345"/>
    <Account Accout="67890"/>

The xsd loaded in the .schemas property of the domObject is:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:b="test:test" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="test:test" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="User">
        <xs:complexType mixed="true">
                <xs:element ref="b:Account" maxOccurs="unbounded"/>
            <xs:attribute name="FirstName" type="xs:string" use="required"/>
            <xs:attribute name="LastName" type="xs:string" use="required"/>
    <xs:element name="Account">
            <xs:attribute name="Account" type="xs:string" use="required"/>

What the listview returns is Line 0 for all errors.

How can I get the actual line positions of the errors when validating the xml?
Is there any XSD for UC AJAX SDK?
I want to generate Java classes by using XJC.

Hello anybody,

One schema I'm referencing in many maps contains the following code snippet:

<xs:attribute ref="xml:lang" use="required"/>


The usage in an XML-file could look like that:


<somename:comment type="explanation" xml:lang="en-us">text</somename:comment>


This is only accepted in my schema if the referenced schema is imported which is done as the following:

<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd" />


But this import causes an error which message states something that the schmeaLocation is not referenced... Solution would be to take the schema-reference local. Also I think it's probably better to have all schemas local on my BizTalk server, so that it has not to download it each time processing files.

I have downloaded the referenced xsd-file and included in my project. Now the (local) import would look like this:

<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="../_w3/xml.xsd" />


The following code snipped could also be included into the schema attributes but it does not affect the result:



Now the problem:

After I did all that mentioned above the schema validates just fine. But when I create an instance of this schema and validate the instance right after with the schema generated from it - it fails!

I'm using this schema in some maps. When I'm testing the map and activate validate output schema it fails with the following error message:

Output validation error: Das Präfix 'ns3' kann keinem Namespacenamen zugeordnet werden, der für "xml" oder "xmlns" reserviert ist.

The case is, that it generates the prefix ns3 instead of xml for this namespace and this is not allowed by xml standarts I guess. The code snippet out of the xml-output from my map looks like the following.



I googled a lot on this but didn't find the solution. Now, I just deactivate output validation for my map and it passed through. But does anybody have an idea how to solve this? Probably I'm not alone with this problem.

Thanks for help, I appreciate.

It there a way to prevent VS from scanning the entire project and auto loading all XSD schema files into the schemaCache

I am using the XML editor to edit schema files, however I have to update the schemas property of the file each time to remove undersirable validations and get the correct ones.


I don't see how to modify XSD in designer mode : I can drag&drop existing (i.e. hand made in code view) items, but cannot add elements nor links between elements.
Furthermore, XML Schema Explorer repeats inserter elements each time I move them in code view...
Am I doing things wrong or is there realy a bug ?

Hi ,

I am validating an xml that express an an invoice document.
this documnt always have header and lines.but somtimes (not always) have serial numbers.
When I am validating the xml against the shcema I want the validator to ignore if the serial number element does not exist.
I can't change and I don't want to change  the schema Since i am getting it from a third party software.
What can I do to ignore it?
see, my code and a part of the schema below:

I am using this code to validate xml file to xsd file:
private void ValidateSchema(string filePath)
            XmlReaderSettings settings;
            XmlDocument doc;
            XmlReader reader = null;
            {  settings = new XmlReaderSettings();
                settings.Schemas.Add(null, m_sSchemaPath);
                settings.ValidationEventHandler += new ValidationEventHandler(settings_ValidationEventHandler);
                settings.ValidationType = ValidationType.Schema;
                doc = new XmlDocument();
                reader = XmlReader.Create(filePath, settings);
                doc.Validate(settings_ValidationEventHandler);            }

this is  part of the the XSD(a few complex type elements):



I am already using a strongly typed dataset, but would instead like to use a custom dataset which inherits from the strongly typed dataset class.  I am unable to find where to set this so when the .xsd/vb files regenerate, it inherits from my custom dataset instead.

It's only one line of code I am really worried about changing in the designer.  The reason being, I am trying to incorporate thread safety with fine granularity.  I am using a ReaderWriterLockSlim in ThreadSafeDataSet which inherits from DataSet, and shadowing/overriding all properties/methods to be locked for reading or writing.

The reason I need thread safety is because we are using custom Query Notifications in which each Notification come in on a separate thread of its own.  These QN's are used to request tables to re-query themselves from the database, unless the QN results from the current client application making the change.

I would override the methods and properties I need in a separate partial class of that dataset, adding thread safety, but just about every property I intend to shadow or override is already implemented.

'''Represents a strongly typed in-memory cache of data.
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", ""),  _
 Global.System.Serializable(),  _
 Global.System.ComponentModel.DesignerCategoryAttribute("code"),  _
 Global.System.ComponentModel.ToolboxItem(true),  _
 Global.System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema"),  _
 Global.System.Xml.Serialization.XmlRootAttribute("Builder"),  _
 Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")>  _
Partial Public Class DesignerDataSet
    Inherits CustomProject.ThreadSafeDataSet
    ' Inherits Global.System.Data.DataSet

Hopefully Helpful,



Dear friends,

Can anyone let me know a good tutorial for learning about the usage of xsd files in .net.

I want to design schema.


Is the "designer  view" of an XSD Schema file somewhere in Beta 2 Visual Studio Professional? I have the "code view" but cannot find a way to switch to "design view". The was something that I use once in awhile in the 2005 VS Professinal Product. The release notes for one of the CTP's of Orcas talked about fast switch and even split screen (design/code) views for editing XSD schemas. Did this get dropped? Was the XSD Designer moved to the more expensive VS SKUs?


The finance industry (and others) have "code lists" / vocabularies / enumerations that are specific to their industries, but an ongoing problem is the maintenance of these lists and the re-design of the "primary" enumeratiuon from time to time.

One approach is "genericode" - an evolving standard for the "generic" code list. There is an OASIS technical committee working on this, and in a few days / a month, v1.0 will be released.

Microsoft is not represented on this Technical Committee, but is an OASIS member.

The Charter of this TC is here  OASIS Code List Representation Technical Committee

Question: What application has XML in Orcas and specifically the "incubation project" called XSD Designer, to solving some of the problems inherent in a generic standard for code lists?


I'm validating XML against a schema (XSD) using the XmlSchema, XmlReaderSettings, ValidationEventHandler, etc as described here: http://aspalliance.com/941_Validating_XML_Files_Against_XSD_Schemas_in_NET_1x_and_20.all

I've found that validation doesn't pick up any errors if the XML and XSD both don't have the "xmlns" property set on the root node. A 3rd party has given me the XSD, and it doesn't have the "xmlns" or "targetNamespace" properties set. If I define an "xmlns" and apply it to the XML and XSD, the problem is fixed and validation picks up errors.

I don't understand. Why do I have to have "xmlns" definined on the XML and XSD (including "targetNamespace" on the XSD) for validation to pick up any errors? Isn't it enough that I added the XmlSchema to the XmlReaderSettings.Schemas collection? Isn't the framework smart enough to know that I want to validate the XML using the XmlSchema I specified?

We are developing an industrial system bound to many kinds of operating system and we want to use a common trace format to view in MS Service Trace Viewer. For this I'd like to have the schema of the trace tags, like the TraceRecord tag.

I'm implementing a "middle ware" solution using service broker to facilitate communications from a non-sql system to a sql based system.  Most, but not all of the intended messages are XML based, and those that are, have an associated XSD.  I need to perform validation against the XSD for all XML messages, and have found that leaving it to service broker to perform to be more than a bit cumbersome and difficult to manage.  I should also mention that all of the ssb communications are amongst different servers, so I would like to perform the validation on the originating server, and if not valid, do not even send the message on.

I think that one potential solution would be to create a parallel set of message types used strictly for validation purposes, and perform the validation prior to handing the message off to ssb.

For example: 

original mesage:  MSG_POUPD (set up in ssb as validation NONE, with all the associated queus, etc.)

validation message: VAL_POUPD ( set up only as a message with schema validation)

When the message is received, validation is performed against the XSD, and if it passes, it is handed off to service broker as MSG_POUPD.  If it doesn't pass, a different path is taken, and the offending message is written to a logging table, and an email is generated.  This would avoid the difficulties with allowing service broker to do the validation, and also make use of existing infrastructure to maintain the information about the messages.

I welcome any opinions or alternative solutions.





<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure