Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

D Cuff

+ Follow
since Feb 16, 2019
Software Developer
Sacramento, CA
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by D Cuff

I don’t know if the query I am trying to do is even possible but if one of you LINQ to SQL/XML guru’s can figure this out I will be so thankful and salute you as a LINQ God. My end goal is to identify all of the XML Models that are duplicates and show the CECID for all the duplicates except one. So lets say I have an Xdocument that looks like this:

Then in SQL Server I have a table called tApplianceTypeColumns that looks like this for a given appliance type:


So here is what I started with but I am far from being close:

So really I want to be able to group by Brand, Model Number, and RegulatoryStatus which are the columns in the tApplianceTypeColumns table that have the ApplianceColumnUnique bit column set to true. The number of true bits could vary depending on the ApplianceTypeID I am looking up in that table. Additionally, I also need to include two elements in the grouping that are never in the tApplianceTypeColumns table and those elements are Action then ManufacturerCode followed by all the other unique elements from the tApplianceTypeColumns in no specific order. So ApplianceTypeID is a known parameter that will be passed to the query. So for any set of duplicates I need to display the CECID for the 2nd and subsequent duplicates so that I can take those CECID’s and do lookups in other tables to change their status. But this first step is tough. I don’t care which of the duplicates does not get displayed. I just need to display all others except 1. I hope I have explained this well enough.

UPDATE: I was able to get a solution for this on Here is a link to the solution.
StackOverflow Solution

1 month ago
Thank you again. You saved me a lot of time and brain cells.
Hi Ron,
I guess we came to the same conclusion once you gave me the extras idea. I had decided to go with this:

So I just figured out that having an xsd:any within an xsd:all is not allowed in XSD 1.0 but will be allowed in 1.1.
So I think I will need to consider your idea of the extra sub tags to make this work. Thanks again!
I just found what I think is what I need.

<xsd:any minOccurs="1" maxOccurs="unbounded" />

But I tried putting this tag after the ManufacturerCode element tag. The validator didn't like it placed there.
It said "The content of 'all' must match (annotation?,elementr*).  A problem was found stating at: any"

Ron: your idea of an Extras tag is interesting. I had not thought of that. If I cannot get the <any> tag to work
then I may consider that. Thank you for the help and the welcome as well.
If I do have to state every tag that will be under Model, then that means I will need to create a different xsd file for every possible ApplianceType and list all the Model sub tags that are specific to that ApplianceType.
Do you think that is the case Ron? or is there a way to state in addition to the stated tags, accept any other various named tags as well?
I do know all the fields for each appliance type but I was trying to avoid having to make a new file for each appliance type. In some cases a single ApplianceType has 80 to 100 fields.
Yes in my example XML size, door and color are the extra elements but they are not real elements I just put them in the example as samples. The number of different optional elements could be in the thousands.
That's why I didn't want to have to put those in the XSD. I was hoping there was a way to state in XSD, to just allow any other tags in addition to the mandatory ones.
Background: I am a C# developer and I am developing a Web Service that will take an XML string as input for various household Appliances and associated details about each model of appliance.
So I am learning more about XML than I ever wanted to and in that process discovered XSD and how awesome it is the validate against the incoming XML. So I am close but not prize with my XSD
and I need help with my specific situation.

So here is how the a valid inbound XML string.

Now here is my XSD coding:

So I want ApplianceModels to wrap all Models and to be able to specify an ApplianceType attribute in the ApplianceModels tag.
Within each Model tag I want to be able to have various fields (sub-tags) about each Model. There are 4 tags that are mandatory
(Action, Brand, ModelNumber, ManufacturerCode) and are the same mandatory tags for any ApplianceType (I want to be able to
use this same xsd for any of about 50 ApplianceTypes). I want to be able to have the mandatory tags be in any order (so I used xsd:all)
but there can only be 1 of each tag within a model (so I set minOccurs and MaxOccurs accordingly).
This may be the difficult part, I also want to be able to have extra tags(fields) along with the mandatory ones. These
extra tags will vary depending on the ApplianceType. I dont need checking on those really but I need to be able to have
as many as I need with no limits. There could 1 or 100 extra of optional these tags and could named just about anything. Is this even
possibly with xsd validation or am I going to have to do this in C# programmatically the hard way.

I hope I am posting this to the right place. Any help would be most appreciated. I have tried many different combinations but can't
get it to validate properly with online XML validators. Thank you in advance. This is my very first XML and XSD project so
please be patient with my 1st attempt at the XSD.