Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / September 2007

Tip: Looking for answers? Try searching our database.

xs:type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Miguel de Melo - 03 Sep 2007 12:22 GMT
Hi,

I have an XML Schema containing inherited complex types, and xs:elements
using @type of the top complex type, meaning, any child complex type can be
an instance of that element by declaring the complex type name using xsi:type
.

If I write the xml by hand, and validate against the xml schema, works
really well.

Using infopath I can import the schema and the data structure is displayed
in the form designer, although there is no apparent way to allow users to
select the xsi:type the instance of that element will be using.

Has anybody used xsi:type with infopath before, or know any way to define
element instance selectors in infopath ?

Thanks
Miguel

Signature

Miguel de Melo (XSLT Architect)

David Dean - 06 Sep 2007 04:02 GMT
InfoPath doesn't recognize this type of schema element. Although you can
import the schema, you will probably not be able to bind the element to any
editable control.

Your schema would probably need to use an <xs:choice> element to allow for a
choice of elements with different datatypes. InfoPath interprets this as a
Choice control. Alternatively, your schema can declare different elements
with different datatypes, then use conditional formatting within InfoPath to
hide or show controls based on the contents of another element that
identifies the desired datatype.

Signature

David Dean
Sr. Member Technical Staff
Insource Technology Corp.

> Hi,
>  
[quoted text clipped - 15 lines]
> Thanks
> Miguel
Miguel de Melo - 06 Sep 2007 08:56 GMT
Hi David,

We’ve tried creating schemas with xs:choice, but unfortunately it represents
illegal XML Schema syntax and (not sure about info path) but most schema
validation tools would fail to validate the schema (even Visual Studio). But
the main problem is that we need the xml to bind to an object model.
So we have no option but to use xsi:type, to define an instance of a complex
type that inherits from another, so we can deserialize the xml back to the
object model.

Is it possible to create dynamic controls using visual basic or c# in Info
path ? This way we might be able to analyse the options and create the
controls on the fly . . .

Thanks
Signature

Miguel de Melo (XSLT Architect)

> InfoPath doesn't recognize this type of schema element. Although you can
> import the schema, you will probably not be able to bind the element to any
[quoted text clipped - 26 lines]
> > Thanks
> > Miguel
David Dean - 06 Sep 2007 12:44 GMT
InfoPath won't let you dynamically add/remove controls, but they can be
hidden or shown using conditional formatting.

If I am to understand your problem correctly, you intend to deserialize the
form XML into the appropriate .NET class instances. Unless you are using
special attributes on your class definitions, I presume that your schema
would need to use different element names to represent different derived
class types so that the deserializer can recognize the correct type of the
instance. You expect InfoPath to be able to show the correct controls
depending on the type of the instance; i.e. if you extend a type by adding a
couple of properties, the UI for the derived type would include a couple of
additional controls bound to these properties.

You might be able to accomplish this in InfoPath using the following
approach and restrictions:
- Use a single element name for the root node of the document
- Where a parent node can contain instances of different complex types,
define an xs:sequence that includes an xs:element for each possible type,
making sure the minOccurs attribute is set to 0.
- In the InfoPath form, add an optional section for each element that
contains the appropriate controls for an element of that type.

To deserialize the XML, you will probably need to include some custom
attributes so that the different element names are deserialized into the
correct types and mapped into the appropriate property of the parent instance.

Signature

David Dean
Sr. Member Technical Staff
Insource Technology Corp.

> Hi David,
>
[quoted text clipped - 42 lines]
> > > Thanks
> > > Miguel
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.