Click here to Skip to main content
16,005,121 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: XSL/Xpath Problem Pin
Dustin Metzgar27-Oct-06 12:21
Dustin Metzgar27-Oct-06 12:21 
GeneralRe: XSL/Xpath Problem Pin
Sarvis27-Oct-06 13:07
Sarvis27-Oct-06 13:07 
GeneralRe: XSL/Xpath Problem Pin
Dustin Metzgar27-Oct-06 14:08
Dustin Metzgar27-Oct-06 14:08 
GeneralRe: XSL/Xpath Problem Pin
Sarvis1-Nov-06 4:35
Sarvis1-Nov-06 4:35 
QuestionCombining xpath queries. please help [modified] Pin
Ista24-Oct-06 5:56
Ista24-Oct-06 5:56 
AnswerRe: Combining xpath queries. please help Pin
Michael Dunn24-Oct-06 7:00
sitebuilderMichael Dunn24-Oct-06 7:00 
GeneralRe: Combining xpath queries. please help Pin
Ista24-Oct-06 7:03
Ista24-Oct-06 7:03 
QuestionXSD.exe and Choice Elements. Pin
craftyFella24-Oct-06 3:32
craftyFella24-Oct-06 3:32 
Given the following XSD File

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Item">
<xs:complexType mixed="true">
<xs:attribute name="uri" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Collection">
<xs:complexType>
<xs:sequence>
<xs:element ref="Item" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Structure">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:documentation>Sequence</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:annotation>
<xs:documentation>Choice Element</xs:documentation>
</xs:annotation>
<xs:element ref="Item">
<xs:annotation>
<xs:documentation>Singular Item (Doesn't have to be a reference)</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="Collection">
<xs:annotation>
<xs:documentation>Collection of Items (Must be a Reference)</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:element name="Count" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

As you can see there is a **choice element ** which has a choice of either a singular Item or a collection of Items. When you use XSD.exe to create the classes in .net you get the following:

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Collection", typeof(Item[]))]
[System.Xml.Serialization.XmlElementAttribute("Item", typeof(Item))]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}

So .NET xsd.exe recognises it’s a choice element and creates the Serialization correctly.

The problem occurs when you try and create a “WebReference” to the web service in a client application. If you look at the reference.cs it has an incorrect version:

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Collection", typeof(ArrayOfItemItem[]))]
[System.Xml.Serialization.XmlElementAttribute("Item", typeof(TestXSDResultItem))]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}


As a result if you try and consume the web service by setting the choice element to a collection and returning that through the WS back into the client application you’ll end up with an empty collection always.

Can anyone help. I've a more detailed explanation and an example application if you want to email me and get that?

All Comments appreciated.

Dave
AnswerRe: XSD.exe and Choice Elements. Pin
BoneSoft27-Oct-06 10:36
BoneSoft27-Oct-06 10:36 
AnswerRe: XSD.exe and Choice Elements. Pin
craftyFella20-Mar-07 5:59
craftyFella20-Mar-07 5:59 
QuestionSQL server 2005 xml value function with pattern matching Pin
Omkar Ghaisas20-Oct-06 9:53
Omkar Ghaisas20-Oct-06 9:53 
AnswerRe: SQL server 2005 xml value function with pattern matching Pin
PavanPareta23-Oct-06 19:36
PavanPareta23-Oct-06 19:36 
Questionhow to stote image file in xml .. [modified] Pin
PavanPareta19-Oct-06 18:59
PavanPareta19-Oct-06 18:59 
AnswerRe: how to stote image file in xml .. Pin
George L. Jackson20-Oct-06 11:53
George L. Jackson20-Oct-06 11:53 
AnswerRe: tag error Pin
Stefan Troschuetz18-Oct-06 5:21
Stefan Troschuetz18-Oct-06 5:21 
GeneralSOLVED Pin
Saira Tanwir18-Oct-06 20:44
Saira Tanwir18-Oct-06 20:44 
Questionexception: The writer is closed Pin
Saira Tanwir16-Oct-06 22:50
Saira Tanwir16-Oct-06 22:50 
AnswerRe: exception: The writer is closed Pin
Stefan Troschuetz17-Oct-06 4:39
Stefan Troschuetz17-Oct-06 4:39 
GeneralRe: exception: The writer is closed [modified] Pin
Saira Tanwir17-Oct-06 21:30
Saira Tanwir17-Oct-06 21:30 
GeneralRe: exception: The writer is closed Pin
Stefan Troschuetz18-Oct-06 4:01
Stefan Troschuetz18-Oct-06 4:01 
QuestionPage footer in xsl Pin
krishna1916-Oct-06 21:10
krishna1916-Oct-06 21:10 
QuestionProblem creating XML Files Pin
farhan197614-Oct-06 21:37
farhan197614-Oct-06 21:37 
AnswerRe: Problem creating XML Files Pin
mnvkng7615-Oct-06 0:52
mnvkng7615-Oct-06 0:52 
QuestionTrying to create attrivbute xsi:schemaLocation [modified] Pin
thomasa13-Oct-06 2:20
thomasa13-Oct-06 2:20 
AnswerRe: Trying to create attrivbute xsi:schemaLocation Pin
Stefan Troschuetz14-Oct-06 1:16
Stefan Troschuetz14-Oct-06 1:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.