How to force XML document to have all fields defined in XSD ?

I use 3.5 I need to be able to create an XML document from another XML and 
XSD filled with all elements even empty ones.

say I have XSD like :

<xs:element name=""RootSchema"">
    <xs:complexType>
        <xs:sequence>
            <xs:element name=""ACcontent"" type=""TContent""/>
....
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name=""TContent"">
    <xs:sequence>
        <xs:element name=""A"" type=""TDescription""/>
        <xs:element name=""B"" type=""TDescription""/>
        <xs:element name=""C"" type=""TDescription""/>
    </xs:sequence>
....


I need an output XML document to have all A B and C elements even if input 
XML only had A and B.

<RootSchema>
    <AContent>
        <A>A...</A><B>B...</B><C/>

I tried to get it through DataSet reading schema, xml and then writing an 
xml but it ignores empty elements
0
Utf
1/18/2010 6:38:15 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
1285 Views

Similar Articles

[PageSpeed] 43

maxima wrote:
> I use 3.5 I need to be able to create an XML document from another XML and 
> XSD filled with all elements even empty ones.

..NET provides a schema object model (SOM) that allows you to load 
schemas in an XmlSchemaSet and then to extract schema information.
See http://msdn.microsoft.com/en-us/library/bs8hh90b.aspx
In addition there is 
http://msdn.microsoft.com/en-us/library/ms172454.aspx, 
XmlSchemaValidator, which allows you to find out required attributes or 
elements.

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
Martin
1/19/2010 12:02:26 PM
Reply:

Similar Artilces:

Forcing a screen repaint??
I would like to know how I can force a display screen repaint. I want to I change the font smoothing setting to ClearType or from ClearType, and have every text item displayed on the screen to be displayed using the selected font smoothing mode. I already know how to change the font smoothing mode. What I need to know is how to force this change to propagate to every item displayed on the screen. You could try using GetDesktopWindow() and call RedrawWindow() with the true arguement. Tom "Peter Olcott" <NoSpam@SeeScreen.com> wrote in message news:waKZh.215274$ZA5....

Extending Field Size in Pivot Tables
Hi - I have been conducting interviews and some of the responses are long. I have tried to put them in a pivot table but there seems to be a field size limit. (By the Way, MS Access is not available). Is there a way I can either extend the field size which would be my preference or can you suggest a different way? Using the lookups as a formula are overwhelming the size of my file. Thanks Carrie -- Message posted via http://www.officekb.com Hi, A little more detail might help what is the structure of your pivot table, what is the error message you are getting, what do you long fields c...

Customize Products HTML Custom Field?
I'm looking for a way to add a formatted description to my products. I'm thinking of using an html doc per each Product. I will then be able to dynamically update my web site and create catalogs on the fly using Quark. I've noticed that the contol in the Email Activity might be useful. Another issue I've encountered is that I'm only able to add simple custom fields to a form (string, number, pick list etc.) through the Schema Manager. Any suggestions on how I should go about this would be greatly appreciated. []P. []V[]. ...

Include a field from previous record on current form
Can anyone explain how I can include a field from the previous record in an unbound text box on a form or report of the current record? I have a form which includes fields for storing the current quantities of liquids in tanks. What I would like to do is show what the volumes were previously on the form as well. I want to be able to view this for any record not just when adding a new record. Thanks One way would be to assign the value to a global variable. The global variable should be declared in a standard module, not in the coe module behind a form. This would keep the level(s) ava...

general question re non numerical character(s) in phone field
I posted a similar question at Skype's forum some time ago but haven't received an answer. Let's say in an Outlook 2007 Contact I wish to denote a mobile phone number as belonging to the spouse of the Contact within the field itself ... H for husband, W for Wife and so forth. If Skype, for example, sees a letter in the field the call is terminated, the reason given - an invalid number. Are there ways to enter non numeric characters in a 'number field' which are then ignored? Thanks, Dave Horne "Dave Horne" <davehorne@home.nl> wrote in message ne...

Office v.X crashes when opening documents
This problem is half due to what appears to be an Apple Mac OS X bug, and half a bug subsequently exposed in Office v.X, I am therefore posting it here to see if I can get feedback on the Microsoft Office v.X issue. The version of Office is v.X with all the available patches including 10.1.5. [ THE APPLE PART OF THE PROBLEM ] I have come across a bizarre problem using Mobile Accounts with Managed Preferences. I would be interested to hear if anyone else can reproduce it. This is affecting all our laptops (and therefore laptop users). All are running Mac OS X 10.3.5 as is the server. As no...

Message by changing one datafield if other fields are filled
Hello, In a database I have, for example, 15 datafields in a record. The first one is the AutoNr, the second one is what I called "the lead" and all the others are information. When I change "the lead" I want a popup 'only' if at least one of the information fields is filled with data. So (I think) I need a changemacro on the second datafield. The macro should do (I think)..... .) count the filled in datafields of the total datafields in the record. .) if the filled in datafields is more then 2 give a popup "blabla" Can somebody (please) help...

XML Import to MM2000
Please bear with me if I ask a question that has been previously addresssed by this group, to which I am new! Is it possible to import to MM2000 a file with extension .FXXML? My bank provides account transactions in that and .CSV formats only and I can only find reference in MM2000 to .OFC and .OFX files. Thanks in advance for any information. Dave "David Spencer" <dispencernomorespam@a1.net> wrote in message news:403b5e78$0$28382$91cee783@newsreader01.highway.telekom.at... > Please bear with me if I ask a question that has been previously addresssed > by this ...

Styles change when someone reviews a document and returns it
Using Word 2007, I'm creating a template that will be used for writing policies. Formatting has become an issue though. If I use the default MS Word styles, the formatting of the document will sometimes change if the doc is sent to someone else for review and that person then returns the document with edits. For example, a text line will no longer be flush with the Heading 1 line above. Is that because that reader's style specifications for Heading 1 might differ from mine even though the style names are the same? If I rename the MS Word styles (e.g., CIP-Heading ...

need to extract (copy) the subject field
I need to extract (copy) the subject field from email folders and the name field from directories or file folders. I need to use this information so that I can write about the files in a readme file, etc. I know how to do this in Unix shell scripts but I do not know how to do it on Microsoft products. I know how to do a screen capture of the info but then I can't manipulate the information without OCR software etc. That's a waste of time. TIA, Gloria .. ...

Excel data merging across excel files and matching field data
I have two excel files each has unique data 1st file: SS, Last Name, First Name... 2nd file: Last Name, First Name, Employee Number I need to copy Employee Number from the 2nd file to the corresponding employee. An employee may be listed more than once in file 1. Thank you , Lorinc EggHeadCafe.com - .NET Developer Portal of Choice http://www.eggheadcafe.com I would assume that the possibility that you might have a Tom Jones *and* a John Jones does exist, so you should check *both* first and last names. Enter this *array* formula in D2 of Sheet1: =INDEX(Sheet2!C$2:C$20,MATCH(1,(She...

XML Send Error
Hi, I'm trying to send (valid) XML using the function below and get an Access Denied Message on the line objXMLHTTP.send(xmldoc) when running the aspx on a Win2003 Server but the very same code works on Win2000 server. Private Function SendToSS3(ByVal Input As String) As String Dim xmldoc As New MSXML2.DOMDocument40 Dim objXMLHTTP As New MSXML2.ServerXMLHTTP40 xmldoc.resolveExternals = False xmldoc.async = False '## Dim Loaded As String = xmldoc.loadXML(Input) objXMLHTTP.open("POST", https://sitename, False) objXMLHTTP.send(xmldoc) Loaded = xmldoc.loa...

trouble adding eXtender fields to smartlist
Hello. I built a simple eXtender window off the Inventory Item Quantities window. I added it to the Item Quantities Smartlist Object (using the Item number & Site to link). I can see the fields in the Smartlist Object, but if I add any to the actual Smartlist I get an error as follows (one per line of data in results): FP: Null Field Address. Form: -43Wind: 372Fld:1310 Error Product: eXtender Script: Get_Window_Key_From_Explorer_Key() of form ExtenderExplorerObject Error Class: EXCEPTION_CLASS_SCRIPT_ADDRESSING Subclass: SCRIPT_CMD_FIELDINFILE Error: Illegal address for field '...

Form Fields Navigation
Hi all, I have a query about navigating within protected Form Fields within Word 2003. By standard (I think), when a form is protected with text form fields within it, using the up and down cursor keys jumps between form fields instead of between lines of text within the formfield. I have tried creating a simple macros: Selection.MoveUp unit:=wdLine, Count:=1, Extend:=wdMove and Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdMove and bound them to the up and down cursor keys but this seems to be ignored when the form is proteced. If anybody has any suggestio...

Bizarre Excel/Word Document Opening Problem
Whenever I open a document in MS Excel 97 or in MS Word 97, I get this strange message: "A document with the name [insert name here] is already open. You cannot open two documents with the same name, even if the documents are in different folders. To open the second document, either close the document that's currently open, or rename one of the documents." But I don't have two documents open. all of my documents have a unique name. This happens all the time, even after restarting. I use Windows XP Home and this has always been the case since I bought the computer. The on...

Good XML-Database?
Hello! I'm looking for a (free, if possible) XML-Database wich is usable from ..NET-Code (especially XPath-Queries and XSLT) I know eXist, but it is only accessible via WebServices or HTTP and the only working method (from .NET) is depreceated (XQuery does not work, it requires some kind of compiler?!) Or: are there any working RDF-Stores for .NET or Win32? There are the W3C-Scripts but I don't want to install even more scripting-environments. Some Java implementations look nice but they have too much features (built-in HTTP-Server, integration with some Apache-Tools) to por...

Smartlist Builder Documentation
It would be very helpful to have documentation on what tables are used to generate the standard smartlists. For example, I want to expand upon the sales transactions smartlist using smartlist builder. So a screenshot of the tables and how they are linked in a builder window would save some effort. Isn't there something like this available somewhere? ...

Slow opening of word document with automation
In the following code with wich I open a word document from access with automation it takes about 20 seconds before the file is opened. What can cause this? I heb tried to disable the viruscontrol but this won't work. I have added 2 msgbox commands to count the time between 1 and 2 and this is about 20 seconds. Sub OpenWordDocument(Documentnaam As String) On Error GoTo HandleErr Dim Teller, AantalWoorden, WordApp As Word.Application On Error Resume Next Set WordApp = GetObject(, "Word.Application") If err.Number <> 0 Then Set WordApp = Cre...

table into Word Document
I have data in the cells of an excel spreadsheet so that it looks like a table. I can print this out and it looks good (margins, font, etc). How can I get this data/table into a Word document without losing the formatting? I have tried inserting a page break into Word and then copying/pasting but that doesn't seem to work. HELP?!!? Thanks Copy the way you were doing it. Then, in Word select: Edit, Paste Special, Formatted text. Suzan "Penny" wrote: > I have data in the cells of an excel spreadsheet so that it looks like a > table. I can print this out and it...

customizing a field in customer maintenance screen
I have a field already on the customer maintenance screen that is a user defined field with a data type of string, but this field only allows 20 characters. This field is not long enough and I can't seem to figure out how to allow more characters. So, I created a new string field and added it into the customer maintenance screen. I can see the field and type text into the field but after I save it and go back in, the text is no longer there. I think I need to link this field to the table in some way but I'm not sure how to go about doing that or even what table to link it to...

Update field names using a query
I have to do a daily import from our accounting software. I have queries created that update a lot of the information that I need. However, I was wondering if there was a way to do a Make table query or an update query that I can rename the field names instead of me mannualy doing it each day. After I clean the data, I have to export it into our leads database and the field names have to match. There are about 15 fields in this import that have to be renamed every day, I was just wondering if I could write some kind of query that could update the field names for me. Thanks for any in...

Accessing the root node of an xml document
Hi Hopefully someone can assist me establish how to access the root node and the first level node of an XmlDocument which I have loaded as per the code below. So far, all I can achieve the output I need with the root node hard and the first node coded. In the foreach I retrieve is next child node ("Customer"). Using ChildNodes[0] fails and no other property or methods of the object return the data I need. private XmlDocument myDoc = new XmlDocument (); myDoc.Load (XMLFileName); txtWriter.WriteStartElement ("CustomersInfo"); // Hard coded txtWriter.WriteStartElement ...

Only Transactions that has special characters in Number field show
One of my customers reported that when they are trying to reconcile bank statement, not all transactions entered in bank transaction window are displayed, while investigating the issue, I did the following: 1. Checked-links. 2. Changed Regional and Language options language for Unicode characters to make sure that this is not a collation error. 3. Reinstalled the application. 4. Tried to use another machine. 5. Checked the knowledgebase, the only solution they provided is to compare CM20200 and CM20500 with no luck. 5. Compared one of the displayed lines with another ...

Parsing an XML file, ERROR: The remote server returned an error: (407) Proxy Authentication Required. HELP!
I'm getting the above error thrown somewhere in the code: XPathDocument xPathDocument = new XPathDocument(FileLocation); XPathNavigator xPathNavigator = xPathDocument.CreateNavigator(); XPathNodeIterator nodeIterator = xPathNavigator.Select("/plist/dict"); nodeIterator.MoveNext(); nodeIterator = nodeIterator.Current.SelectChildren(XPathNodeType.All); where FileLocation contains the full path of a local XML file. Why is this trying to access the file via the proxy ? What can I do to fix this ? JezB wrote: > I'm getting the above error thrown somewhere in the code:...

Document Library Metadata
Recently, we had a user report a problem with saving metadata in one of our document libraries (reported recently, but no telling how long it was going on without being reported). The library uses a pre-made excel file as the template, and has two pieces of metadata that it prompts the user for on save. Uploading a document to the library works just fine, but when saving directly to the library from Excel, it prompts for the metadata, and then does not actually save it to the library. Going back in after the fact and adding the information again also works fine, but we cannot ...