0

Ok, here is specific case scenario:

My application is going to receive some XML inputs. Then the application needs to render that XML input, as well as do some calculations after parsing data from that XML input.

The deal is, that the application is data agnostic. It's code cannot know details about XML data and format during design-time. So am making it the responsibility of calling client tool to send a schema associated with the XML data. Based on that schema, application will parse and understand XML data it will receive.

So, questions: Can XML Schema specify any custom attributes that I may decide my application will need to parse data? Will it be ok if corresponding node in XML data will not specify those attributes themselves? While navigating in XML data, node by node, how can I using C# load corresponding attributes and values from XML schema?

Basically, I'll need such custom attributes in schema for various nodes - showInTable, isPrimary, graphable etc etc

Thanks for help.

StackCoder
  • 81
  • 8

1 Answers1

0

The way around this I would say is to have a some fixed part of the schema, for data that will be there - even if it is nullable.

Then after that, get the XML to use some sort of <metadata> tags to allow you to capture any additional information. Like

<Customer>
   <Name>Joe Bloggs</Name>
   <Age>65</Age>
   <Metadata key="Criminal History">Grand Theft Auto</Metadata>
   <Metadata key="Favourite Colour">Blue</Metadata>
</Customer>

Metadata can be shared (if defined up front), with a minOccurs='0', maxOccurs='unbounded'.

Dominic Zukiewicz
  • 8,258
  • 8
  • 43
  • 61