Schema element default attribute does not work?

I have tried to set a default value in my schema element definition, but it 
does not seem to work. That is, when I try to "getElementsByTagName()" 
against a tag that was not specified in the xml, but _was_ defined in the 
xsd, I get an empty return. I expected to get an element that matches the 
default value.

I am using VBScript and MSXML6.0.

This is what my xsd looks like:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- definition of simple elements -->
<xs:element name="ScenarioName"       type="xs:string" />
<xs:element name="SimString"          type="xs:string" default="*" />

<!-- definition of complex elements -->
<xs:element name="run">
    <xs:complexType mixed="true">
        <xs:all>
            <xs:element ref="ScenarioName"       minOccurs="1" maxOccurs="1" 
/>
            <xs:element ref="SimString"          minOccurs="0" maxOccurs="1" 
/>
        </xs:all>
        <xs:attribute ref="runId" use="required" />
    </xs:complexType>
</xs:element>

<xs:element name="scenarioBatch">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="run" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

</xs:schema>

My xml file is:

<?xml version="1.0" standalone="no"?>

<scenarioBatch
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:///C:/Scripts/ScenarioBatchList.xsd">

    <run runId="Run02">
        <ScenarioName>Rt_Batch1_Circular_RT_99X_2Hr_2RTA</ScenarioName>
    </run>
</scenarioBatch>

and my VBScript is:

    ' Load the scenario list from the file
    Set objsbxFile = CreateObject("Msxml2.DOMDocument.6.0")
    objsbxFile.validateOnParse = true
    objsbxFile.resolveExternals = true
    objsbxFile.async = false
    objsbxFile.load sbxFile
    if (objsbxFile.parseError.errorCode <> 0) Then
        Call DebugLogger(DebugLevelAlways, "Error loading SBX file (" & 
sbxFile & "): " & objsbxFile.parseError.reason)
        Wscript.Quit()
    end if

    set sbxRuns = objsbxFile.getElementsByTagName("run")
    
    ' show what was read
    for each Elem in sbxRuns
        Call DebugLogger(DebugLevelInfo, "RunId = " & 
Elem.getAttribute("runId"))
        set sbxScenarioNames = Elem.getElementsByTagName("ScenarioName")
        Call DebugLogger(DebugLevelInfo, "ScenarioName = " & 
sbxScenarioNames(0).nodeTypedValue)
        set sbxSimStrings = Elem.getElementsByTagName("SimString")
        Call DebugLogger(DebugLevelInfo, "SimString = " & 
sbxSimStrings(0).nodeTypedValue)
        
    Next

0
10/26/2009 7:29:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
1676 Views

Similar Articles

[PageSpeed] 46

PixelPusher wrote:
> I have tried to set a default value in my schema element definition, but it 
> does not seem to work. That is, when I try to "getElementsByTagName()" 
> against a tag that was not specified in the xml, but _was_ defined in the 
> xsd, I get an empty return. I expected to get an element that matches the 
> default value.

I think you misunderstand what default values for element means. If the 
element is empty then it takes on the default value. If the element is 
missing as in your sample then it is _not_ inserted.

See http://www.w3.org/TR/xmlschema-1/#cElement_Declarations
which says
    "{value constraint} establishes a default or fixed value for an 
element. If default is specified, and if the element being ·validated· 
is empty, then the canonical form of the supplied constraint value 
becomes the [schema normalized value] of the ·validated· element in the 
·post-schema-validation infoset·. "

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
mahotrash (1777)
10/27/2009 10:41:05 AM
Martin,
Thanks for the information. That is what I was starting to suspect. I was 
hoping to not need to know the default values of elements in the schema 
within the code that interprets the xml. I guess that is not possible.

Thanks again.
Thom


"Martin Honnen" wrote:

> PixelPusher wrote:
> > I have tried to set a default value in my schema element definition, but it 
> > does not seem to work. That is, when I try to "getElementsByTagName()" 
> > against a tag that was not specified in the xml, but _was_ defined in the 
> > xsd, I get an empty return. I expected to get an element that matches the 
> > default value.
> 
> I think you misunderstand what default values for element means. If the 
> element is empty then it takes on the default value. If the element is 
> missing as in your sample then it is _not_ inserted.
> 
> See http://www.w3.org/TR/xmlschema-1/#cElement_Declarations
> which says
>     "{value constraint} establishes a default or fixed value for an 
> element. If default is specified, and if the element being ·validated· 
> is empty, then the canonical form of the supplied constraint value 
> becomes the [schema normalized value] of the ·validated· element in the 
> ·post-schema-validation infoset·. "
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://msmvps.com/blogs/martin_honnen/
> .
> 
0
10/27/2009 1:18:10 PM
Reply:

Similar Artilces:

Excel 12, insert chart does not work. Exel restart. Why?
When I insert chart and select chart data, MS Office encounters a problem and need to close. Another thing: On chart tools the desings are empty. Any solution? In article <A678D3D8-566D-46A1-8A19-5F85D34BB2C8@microsoft.com>, tujauja@discussions.microsoft.com says... > When I insert chart and select chart data, MS Office encounters a problem and > need to close. > Another thing: > On chart tools the desings are empty. > Any solution? > Office 12 is still in beta. You should have received information from MS about where and how to post questions about it. -- Rega...

Office 2004 on Intel works, for a while, then apps will not launch
Hello all! I searched previous posts extensively before posting. But my problem does not seem to come from corrupted fonts or preferences. Problem : Office apps work fine after a reboot, but eventually, I become unable to relaunch them. I have to reboot again to get them to work. Details : MacBook Pro, 1gig of ram. Office 2004 11.2.6. OS 10.4.7. I'll open Entourage, work a bit, close it, and then I can't open it anymore. The splash screen does not even appear completely (white rectangle). Console gives : ***** Date/Time: 2006-08-09 12:03:11.089 -0400 OS Version: 10.4.7 (...

Defaults for Public folders
Is there a way to automatically have public folders use the public store defaults when I create a new folder? I create a lot of folders and I have I have to change the item size limit on every folder and would rather just have it do it automatically. Thanks, Sander System policies - Public store policy is what you want. Regards, Boris "Sander" <noemail@noemail.com> wrote in message news:%23kj%23vJj3EHA.536@TK2MSFTNGP10.phx.gbl... > Is there a way to automatically have public folders use the public store > defaults when I create a new folder? I create a lot o...

Item Wizard for Matrix Item, 2.0, Attributes Problem, Fix w/SQL co
Next on my list......when we used new item wizard in 1.2, and set attributes for a matrix item (always color, size and style, in our case), the computer automatically plugged those into the individual attribute field for each item. They then showed up on our label format (we have 3 boxes at the bottom where the color, size and style would be plugged into). After upgrading to 2.0, those attributes no longer go into the individual item fields automatically (although they do get plugged into the description). Any idea how to fix this? Ideally, I'd like them back on the label as well.....

DEFAULT TEXT BOX FONTS
Hi, In Publisher 2003, it's possible to set fill and line settings as defaults, so that when you create a new text box it automatically uses them . . . However, does anyone know of a way to associate a font (or preferably a style) with new text boxes, so that when you create one the correct typeface is automatically selected? Thanks Open the Font Schemes from the format menu, click "Styles and Formatting", click Create new style. Setting Text Defaults using Normal.pub http://ed.mvps.org/Static.aspx?=Publisher/normal.pub Right-click the text box, click format text box, C...

How to get attributes from other entities in JScript
I have 3 entities In one of them I need an onChange script on an attribute that requires variables pullled from other entities. AFAIK, you cannot include variables in Jscript that are not attributes in the entity. Is that right? What ar ethe alternative solutions? pre-callout? Thanks -- Paul Doyon CRM Consultant ...

XML samples for replace a child element
Hi, Does anybody know where I can find samples to search an element in a subtree of an xml file and replace some new value for this element? I can only find some samples to use 'replace last child or replade first child' but couldn't find sample for replace a child neither first nor last child. Thanks for any help, CT See http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlXmlNodeClassReplaceChildTopic.asp Rather than specifying root.FirstChild or root.LastChild, you only need to select a particular node. Supposing you have the root node of the dom document (r...

Organize
I've used the Organize Wizard to sort emails from specific people into specific subfolders within the Inbox. Prior to discovering the Wizard I was manually specifying where an email I had received should go in the future. I think some of these attributes still remain on 1 or more addresses as when I receive an email from a specific person a copy goes to 3 different locations! 1 to the Inbox, one to a subfolder within Inbox (this is the correct one), and one to a subfolder within Sent Items (a mistake I had made earlier on). Can anyone explain how to remove attributes from all incoming em...

Why does Autoexpand in combo box not work with accented characters?
To quote the Access online help: You can use the AutoExpand property to specify whether Microsoft Access automatically fills the text box portion of a combo box with a value from the combo box list that matches the characters you enter as you type in the combo box. This lets you quickly enter an existing value in a combo box without displaying the list box portion of the combo box. This works fine when I use the normal English alphabet, but fails if I type an accented character as the first character of a name in a foreign language such as Hungarian. Is there any way to make AutoExpand ...

java srcipt not working, getting about blank page
i have windows xp recently i have been getting a blank page behind the page im trying to open, mainly pogo games or playsite games, i have all new updates from microsoft installed, but i cant change calender set up either, what di i need to do This newsgroup is for questions related to Microsoft Publisher. You would be better off posting your question to the appropriate group. -- JoAnn Paules MVP Microsoft [Publisher] "the big bud man 8" <the big bud man 8@discussions.microsoft.com> wrote in message news:BED6D77A-DD80-48B8-A58A-1FC98613ED2A@microsoft.com... >i hav...

Physical Inventory Does Not Work With Matrix Items.
The physical inventory feature in RMS is not usable with matrix type items. It is impossible to filter the inventory count down to a managable number of items for a matrix items. The items I sell consist of a model name, a size, and a color. The matrix lookup code (model name) is not available as a filter. When I try to filter the physical inventory list I get thousands of irrelevant items mixed in with what I want to inventory. I would suggest that the item lookup code be added as a filter for the physical inventory. I would also suggest that when you make a matrix inactive that it ...

Custom Tool bar button on Contacts/Leads/Account Forms Intermittently not working.
Hello CRM gurus, I have a weird issue with a clients web CRM 3 client. I have modified the 'isv.config.xml' and 'isv.confg' files to add a custom button to the contacts/leads/account forms. What seems to be happen, at times (seems to be random) the picture of the button doesn't show up, but the text does and the you cannot click on the button anymore. It only happens to one client PC, as the rest of the client PCs work without any problems. I have run out of ideas as to why this is occurring. Are there any log files that I can look at? Any help on this problem will be g...

autocomplete addresses not working
I have just set up an account and imported my contacts via a windows csv file, now when I start a new mail and start to type in the 'To' field the address isn't automatically recognised. I have the settings correct in Advanced e mail settings. Can this be restored? You will restore it when you send enough messages to populate your autocompletion cache. That's what Autocomplete uses, not your Contacts. Autoresolution (Automatic Name Checking) uses your Contacts Data. -- Russ Valentine [MVP-Outlook] "Headtheball" <noanswer@hotmail.com> wrote in message ...

Outlook Express Delete not working
Windows XP Home Outlook Express won't let me delete all my deleted emails at one time. I can only do won at a time. In the EDIT, the (delete all deleted messages) isn't highlighted. Is there a quick fix for this? Hi Jack, Open Outlook Express. Click Tooks at the top then click Options. Click Maintenance. Check the first option. Click Apply then click OK. Close Outlook Express. Open Outlook Express. Check the folder. -- thecreator "Jack" <Audioman1@myway.com> wrote in message news:ehU1082ALHA.98...

Copying Attribute
I need to create a bunch of attributes which will all have the same picklist. Is there a way to save the list so I can replicate it? Also, is there a way to save any attribute so I can duplicate it multiple times and save it as a different name rather than having to start from scratch each time? If so, how? I want to know the same thing. In addition, is it possible to group attributes? I would like to group a section of fields, copy this section and preserve the picklist values. "Kenbo" wrote: > I need to create a bunch of attributes which will all have the same pickl...

Exchange 2007
Hallo. we have enabled recipient filtering for our organization as we are requested to reject with a SMTP connection error messages addressed to non existent recipients as follows: EMC - Organization Configuration - Hub Transport - Anti-spam - Recipient Filtering enabled Block messages sent to recipients not listed in the GAL Still, if I telnet on port 25 I get a 250 2.1.5 Recipient OK message to a RCPT TO:non_existent_user@mydomain.com We have 2 Exchange 2007 SP1 servers: both are HubTransport+ClientAccess+Mailbox+UnifiedMessaging Exch1 is Windows Server 2003 Ent R2 SP2 ...

Why my setting doesn't work?
I am trying to write a program similar to "ping".Like the example provided in MSDN,I call setsockopt function to set SO_RCVTIMEO value for my raw socket.And before I make a call to recvfrom,I call getsockopt to ensure that the value ihas been correctly set,and it has.But recvfrom does not return automatically when the specified timeout is exceeded,conversely ,it gets stuck permanently if no packet can be received. If anyone knows why ,could you please tell me what I should do to get the result I want?Thank you in advance for you help. ...

Spam Program that works on Public Folders
Hello, I currently use SpamNet for spam filtering, and it works great. However, some my messages get delivered to a Public Folder (Outlook 2003 / Exchange 2003) and those messages are not filted by SpamNet. Does anyone know of a Spam program that works on emails that show as posts in an Exchange Public Folder? Thanks, Gerald Try www.spambayes.org Gerald S schrieb: > > Hello, > > I currently use SpamNet for spam filtering, and it works great. > However, some my messages get delivered to a Public Folder (Outlook 2003 > / Exchange 2003) and those messages are not filte...

Resetting default row height to allow display of wrapped text
I'm using Excel 2000 and XP Pro. I'm formatting a text page whereby users can input text into a column and I want the text to wrap so that whatever the length of their text we see it all. On a default page it works fine. However I tinkered with the row height for font purposes and now the text will wrap but the row won't expand to fit the whole text. How do I reset the row/sheet or whatever to get the display I want? Thanks -- Stilson Snow There is a limit to how much text will display within a cell and how much text displays in the formula bar. Goto excel help and enter...

Tab key press does not work when MS flex grid presend on CFormView Based views
When dynamically create a MS Flex Grid based grid control on a CFormView based view in MFC application, tab will stop working after one press which will put the last columns header of the grid control in focus and you could not tab anymore. You have to move the carrot to another control on the view manually using mouse, then the tab will start working again. This only happens with the .NET VS 2003 and 2005 compiler. Hi Dennis, I have performed some tests on this issue and could repro the problem in our side. In VS2003 and VS2005, if the MSFlexGrid control created dynamically withi...

I cannot select any text or elements on my page in Publisher 2007
When trying to select text elements and graphic elements on a page of a multi page document, I am unable to select anything although I have been editing the document previously. Can the file be locked in any way You may have a border around the pages that sits in front preventing your selecting the objects. You can send the border to the back. Open the "Graphics Manager" in the Tools menu. Use the drop down to select the pictures. -- Mary Sauer http://msauer.mvps.org/ "Bluesea124" <Bluesea124@discussions.microsoft.com> wrote in message news:B1CE9B5A-D171-40B9...

OWA not working
We are migrating from exchange 5.5 to exchange 2003. We used the exdeploy tool to guide us through the migration..joined the exchange 2003 server to an existing 5.5 site, moved the mailboxes over to the exchange 2003 server using system manager and then logged in with each users account so outlook would detect the new server. The only thing that is not working is the OWA. On each computer the web address defaults back to the old mail server login page. What needs to be done? ...

Out of Office Assistant Doesn't Work
Hello, I have one user who put their Out of Office assistant on, but it is not replying to any incoming messages. She has no rules setup in her Outlook. The config is Exchange 2003 and she has WinXP with Oulook 2003. Thanks, George Define not working. Not working for "anyone"? Do you get an Out of Office message if you send a message to her? By default, Out of Office to the Internet is disabled, but any internal users should get the OOF message. -- Ben Winzenz Exchange MVP MessageOne Read my blog! http://winzenz.blogspot.com http://feeds.feedburner.com/winzenz (RSS Feed) ...

Offline address list
What AD attributes make up the OAB? Attributes don't make up the OAB. The oab is filtered copy of the global address list. Each object in the gal (mail-enalbed object, contact, dl, etc) will be comprised of 40+ viewable attributes that are stamped on each object that you can look at (Display Name, Phone Number, etc). If you want to view all of the attributes that are stamped on a object in the global address list, you can download a copy of OABInteg and run the following command line switches: oabinteg /s:exchsrvrname /t:[ getabinfo_v2 or getabinfo_v3 or getabinfo_v4 ] /l /v:2 ...

launch excel attachment from outlook
problem: double clicking on excel attachments in outlook email results in an error message "the system cannot find the file specified" excel appears to start (new) - but file never opens file can be saved and subsequently opened from excel 2007. file cannot be launched by double clicking on it. thoughts? Try this Office button>Excel options Advanced>General...ignore other applications... -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "chris B" <chrisB@discussions.microsoft.com> wrote in message news:D484E8CC-5788-48A2-9307-D6381796F2FE@m...