promoting "type" attribute from XMLSchema-instance as a property f

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



In Biztalk 2006, I have a message schema which defines two complex types, one
derived from the other. The schema defines one element of the base complex
type. Here is that schema:
--------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="poly"
targetNamespace="http://BiztalkTest1.PolyEvents";
elementFormDefault="qualified"
xmlns="http://BiztalkTest1.PolyEvents";
xmlns:mstns="http://BiztalkTest1.PolyEvents";
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
<xs:complexType name="EventBase">
<xs:sequence>
<xs:element name="Description" type="xs:string"/>
<xs:element name="EventTime" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="LocatedEvent">
<xs:complexContent>
<xs:extension base="EventBase">
<xs:sequence>
<xs:element name="LocationID" type="xs:integer"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="TheEvent" type="EventBase" />
</xs:schema>
--------------------------------------------------
I can create XML instance documents that contain either one element of the
base complex type, as follows:
------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<ns0:TheEvent xmlns:ns0="http://BiztalkTest1.PolyEvents";>
<ns0:Description>poly base event 1</ns0:Description>
<ns0:EventTime>1999-05-31T13:20:00.000-05:00</ns0:EventTime>
</ns0:TheEvent>
------------------------------------------------------
or a can utilize http://www.w3.org/2001/XMLSchema-instance's "type"
attribute to create an XML instance document that contains one element of the
derived complex type, as follows:
------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<ns0:TheEvent xmlns:ns0="http://BiztalkTest1.PolyEvents";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="ns0:LocatedEvent">
<ns0:Description>poly located event 1</ns0:Description>
<ns0:EventTime>1999-05-31T13:20:00.000-05:00</ns0:EventTime>
<ns0:LocationID>123</ns0:LocationID>
</ns0:TheEvent>
------------------------------------------------------
In some cases, I want to be able to configure an orchestration's receive
shape to only activate the orchestration if the type is the derived complex
type ("LocatedEvent" type.) I think the only way I can do this is to promote
the schema-instance "type" attribute as a property field. I tried to do this
by creating a property field (called "ns0:MyEventType") and then hand-editing
the XPath to be the following:
----------------------------------------------------------------
/*[local-name()='TheEvent' and
namespace-uri()='http://BiztalkTest1.PolyEvents']/@*[local-name()='type' and
namespace-uri()='http://www.w3.org/2001/XMLSchema-instance']
---------------------------------------------------------------
This results in the editor dialog to return an error "Some promoted
properties may be invalid. Do you wish to continue? The following promoted
properties may contain invalid XPaths: ns0:MyEventType". I don't understand
why this doesn't work, because this XPath works fine in a c# winforms test
app I wrote (using XmlDocument.SelectNodes().) Any ideas? I'm sure I could
add extra attributes to my schema that I then restrict to fixed values in the
derived types, but that seems to duplicate XMLSchema-instance functionality.
I know I could create different message types for each complex type I want to
receive, and then use the std. message type routing, but in many cases I have
orchestrations that will want to receive many different message types, and it
seems cumbersome and a maintenance headache to keep adding different port
operations and receive shapes for each message type.

Any ideas? Thanks!
.



Relevant Pages

  • Re: C# code generation with xsd.exe "how to ?"
    ... Check the article titled Code ... Generation in the .NET Framework Using XML Schema on MSDN ... In order to get classes that inherit from others, ... define a Person complex type, and make the ExtendedPerson complex type ...
    (microsoft.public.dotnet.xml)
  • Re: Could anyone explain this schema structure?
    ... > XML schema language that element always has a complex type, ... This is inheiritance in the same vein as in OOP. ... I have to say though, you are right, I dont like it. ...
    (comp.text.xml)
  • Extensible enumerations in XML Schema
    ... I have a complex type that has one ... The XML schema that I define ... items to the enumeration in an additional schema. ... includes the enum values of the original/parent simpleType. ...
    (comp.text.xml)
  • Re: Query on elementFormDefault & Restrictions (using AltovaXmlSpy)
    ... "The content model of complex type '' is not a valid ... Your restriction attempts to restrict that with an element declaration ... in the base schema document and 'unqualified' in yours, ...
    (comp.text.xml)
  • Re: Promote Complex Type
    ... If you know the XPath to use, ... open the schema in a text editor and add the property annotation by hand. ... > items that I would like to promote is a complex type, ...
    (microsoft.public.biztalk.general)