.Net XmlValidatingReader should fail on complextypes with whitespace?

I believe the .Net XmlValidatingReader should fail when validating XML 
that contains a ComplexType element with white space when the 
ComplexType element has the mixed attribute set to false in the XSD used 
for validation.

XSD fragment:

<xs:element name="TRSellerBuyerData">
	<xs:complexType mixed="false">
		<xs:sequence>
			<xs:element ref="BuyerSellerReferrorFlag" minOccurs="0" 
maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
</xs:element>

XML fragment:

<TRSellerBuyerData>
</TRSellerBuyerData>

XML Spy will catch the valdation error and report: "Text not allowed 
inside element 'TRSellerBuyerData'

But the following code does not catch the validation error.  Is this a 
bug in XmlValidatingReader - or am I missing code to catch this?  I 
assume by XSD is correct since XmlSpy catches the error.


XmlTextReader textReader = new XmlTextReader(reader);

textReader.WhitespaceHandling = WhitespaceHandling.All;  //this is the 
default

textReader.Normalization = false;	//this is the default

XmlValidatingReader validatingReader = new XmlValidatingReader(textReader);

validatingReader.ValidationType = ValidationType.Schema;
			
validatingReader.Schemas.Add(schemaCollection);

try
{
	while(validatingReader.Read());
}
catch(Exception ex)
{
	Debug.WriteLine(ex.Message);	
}


-Larry
0
larry7661 (4)
6/4/2004 8:00:32 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
590 Views

Similar Articles

[PageSpeed] 0

The following complexType's ContentType is ElementOnly according to
structures spec. (http://www.w3.org/TR/xmlschema-1)
and if the ContentType is ElementOnly, then whitespace characters are
allowed according to clause 2.3 of the following rule in the spec:
3.4.4 Complex Type Definition Validation Rules
Validation Rule: Element Locally Valid (Complex Type)
2.3 If the {content type} is element-only, then the element information item
has no character information item [children] other than those whose
[character code] is defined as a white space in [XML 1.0 (Second Edition)].

Thanks,
Priya


"Larry" <larry@nospam.net> wrote in message
news:z_Vvc.343$4S5.259@attbi_s52...
> I believe the .Net XmlValidatingReader should fail when validating XML
> that contains a ComplexType element with white space when the
> ComplexType element has the mixed attribute set to false in the XSD used
> for validation.
>
> XSD fragment:
>
> <xs:element name="TRSellerBuyerData">
> <xs:complexType mixed="false">
> <xs:sequence>
> <xs:element ref="BuyerSellerReferrorFlag" minOccurs="0"
> maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> XML fragment:
>
> <TRSellerBuyerData>
> </TRSellerBuyerData>
>
> XML Spy will catch the valdation error and report: "Text not allowed
> inside element 'TRSellerBuyerData'
>
> But the following code does not catch the validation error.  Is this a
> bug in XmlValidatingReader - or am I missing code to catch this?  I
> assume by XSD is correct since XmlSpy catches the error.
>
>
> XmlTextReader textReader = new XmlTextReader(reader);
>
> textReader.WhitespaceHandling = WhitespaceHandling.All;  //this is the
> default
>
> textReader.Normalization = false; //this is the default
>
> XmlValidatingReader validatingReader = new
XmlValidatingReader(textReader);
>
> validatingReader.ValidationType = ValidationType.Schema;
>
> validatingReader.Schemas.Add(schemaCollection);
>
> try
> {
> while(validatingReader.Read());
> }
> catch(Exception ex)
> {
> Debug.WriteLine(ex.Message);
> }
>
>
> -Larry


0
priyal (31)
6/4/2004 9:18:02 PM
Thank you Priya, how would I change my XSD so that only child elements 
are allowed and no "significant" white space?

Priya Lakshminarayanan [MSFT] wrote:
> The following complexType's ContentType is ElementOnly according to
> structures spec. (http://www.w3.org/TR/xmlschema-1)
> and if the ContentType is ElementOnly, then whitespace characters are
> allowed according to clause 2.3 of the following rule in the spec:
> 3.4.4 Complex Type Definition Validation Rules
> Validation Rule: Element Locally Valid (Complex Type)
> 2.3 If the {content type} is element-only, then the element information item
> has no character information item [children] other than those whose
> [character code] is defined as a white space in [XML 1.0 (Second Edition)].
> 
> Thanks,
> Priya
> 
> 
> "Larry" <larry@nospam.net> wrote in message
> news:z_Vvc.343$4S5.259@attbi_s52...
> 
>>I believe the .Net XmlValidatingReader should fail when validating XML
>>that contains a ComplexType element with white space when the
>>ComplexType element has the mixed attribute set to false in the XSD used
>>for validation.
>>
>>XSD fragment:
>>
>><xs:element name="TRSellerBuyerData">
>><xs:complexType mixed="false">
>><xs:sequence>
>><xs:element ref="BuyerSellerReferrorFlag" minOccurs="0"
>>maxOccurs="unbounded"/>
>></xs:sequence>
>></xs:complexType>
>></xs:element>
>>
>>XML fragment:
>>
>><TRSellerBuyerData>
>></TRSellerBuyerData>
>>
>>XML Spy will catch the valdation error and report: "Text not allowed
>>inside element 'TRSellerBuyerData'
>>
>>But the following code does not catch the validation error.  Is this a
>>bug in XmlValidatingReader - or am I missing code to catch this?  I
>>assume by XSD is correct since XmlSpy catches the error.
>>
>>
>>XmlTextReader textReader = new XmlTextReader(reader);
>>
>>textReader.WhitespaceHandling = WhitespaceHandling.All;  //this is the
>>default
>>
>>textReader.Normalization = false; //this is the default
>>
>>XmlValidatingReader validatingReader = new
> 
> XmlValidatingReader(textReader);
> 
>>validatingReader.ValidationType = ValidationType.Schema;
>>
>>validatingReader.Schemas.Add(schemaCollection);
>>
>>try
>>{
>>while(validatingReader.Read());
>>}
>>catch(Exception ex)
>>{
>>Debug.WriteLine(ex.Message);
>>}
>>
>>
>>-Larry
> 
> 
> 
0
larry7661 (4)
6/4/2004 11:14:43 PM
Reply:

Similar Artilces:

C#.net click event associated with database error
I would like to know what to do to solve the problem listed below: When I am debugging a C#.Net 2008 windows application and click on the 'next' button, I am getting the following error: 'An unexpected error has occurred. The 'Microsoft.jet.oledb.4.0'provider is not registered on the local machine'. I think that I may need to change some setting I have in the visual studio.net 2008 professional edition to solve this problem prior to clicking on the 'next' button. I am working on an workstation that is 64 bits, XP operating syste...

net passport
I changd my net passport and now when I enter it in money it tells me it is incorrect. ...

database integrity checks failing
Hello: We have two database integrity checks jobs in SQL 2005 that are failing. One job is for our financial app databases, while the other is for the SQL system databases. I know how to conduct the typical fix for the financial app databases--run DBCC CHECKDB to find the questionable tables that require the DBCC UPDATEUSAGE script run against those tables. But, it concerns me that the database integrity job against the system databases is failing. Regardless, can I safely run the same DBCC CHECKDB and DBCC UPDATEUSAGE scripts to eliminate the issues causing the system d...

net
Dear All , Can you please help in this i'm creating excel sheet for finance purpose and i need the number appear with color for example if the net = +ve (i need it to appear with green color ) and if it is = - neg (i need to appear with red color ) any one can help me with the color thansk for your cooperations -- bn_dubai ------------------------------------------------------------------------ bn_dubai's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29568 View this thread: http://www.excelforum.com/showthread.php?threadid=492656 You can use Con...

MFC and .NET
We have a MFC application we are moving to VC 7.0 because we want to use the latest C++ compiler that comes with it. For moving to VC 7.0 we need to install the .NET framework though. My questions are, 1. Has anybody moved thier MFC application to .NET framework? Did you run into any issues? 2. What is the plan for MFC? Is there any end of life for this from Microsoft? Thanks, David I use all of my VC6 MFC apps and DLLs just fine with XP and VS.Net 2003. No need to port your code to .Net at all. WTH "David Mohandas" <david_mohandas@yahoo.com> wrote in message news:ac...

VB.net
Hi, I am trying to update a field in a record of a Access Database (whose structure I can not modify). I got this error (translated from italian): "Data types do not match in the expression" = "Tipi di dati non corrispondenti nell'espressione criterio." The code is the following: (myField is a binary field as on Access 2007) 'determine new value Dim newValue() As Byte = ... (valid data) 'write new attributes Dim conn As OleDbConnection = myObj.getConnection Dim cmd As OleDbComman...

Authentication between asp.net 2.0 and asp.net 1.1
I am running CRM 3.0 which is running in its own app pool for asp.net 1.1. I've added a virtual directory under the CRM website which runs under a different app pool for asp.net 2.0. This is where I put my custom web pages. Both app pools are running under the NETWORK SERVICE account. Both the CRM website and the virtual directory has windows authentication. My question is why I am prompted to enter my credential when I access the custom page through CRM the first time I access the page? Have I not already been authenticated? Hmm not sure whether this can help. Are you sure you put...

Office Genuine Advantage Notifier update failed
XP Pro SP2 - KB949810 update failed, multiple times. Went to the MS suggested fix page and noted they wanted me to go in and fool around with the registry. Well, I don't do 'registry'. So, can I just block this update from being listed and go about my updates and other business with no future problems, OR, is this thing going to jump up and bite me in the rear at some point in time? If it's going to cause a future problem, is there a simpler fix than the convoluted registry tweaks suggested by MS? Why isn't SP3 installed yet? See http://www.mydigitallife...

SQL connection management in ASP.Net
hi, I have to create a small website in ASP.Net 2.0. I have question about working with SQL connections. What are the best practises? How and where to create and store a connection? I see a few possibilities: - create, open/close a connection on each web page - create a connection on login page and store it on Session - how to create a connection? ie. SqlConnection = new SqlConnection or System.Data.Common.DbProviderFactory factory = System.Data.Common.DbProviderFactories.GetFactory("System.Data.SqlClient"); System.Data.Common.DbConnection conn = factory.Crea...

FREE .NET EBOOKS , DOTNET TUTORIALS, CODE SNIPPETS
Visit this site u will find good .Net ebooks, .Net source code, .net tutorials and lots more for vb.net, c#.net, asp.net and other dotnet stuff. URL: www.DotNetGuide.net I don't like the site because 1) There are 3 sets of adverts on each page 2) The page is fixed with, which is very annoying. I am reading on a wide-screen laptop but find I am limited to approximately 60 characters per line, I can't read articles like that! Pete ...

xml DTD visual stdio .net 2k3 autocomplete
Hello, I'm using visual studio .net 2k3 to work with Xml intensive integration App. When I using XML /XSD based documents I get autocomplete feature but not when I use Xml /Dtd based. Somebody know How work around Thansk Alejandro P. ? <alejandropacheco@hotmail.com> wrote in message news:esj0OEWYEHA.2972@TK2MSFTNGP12.phx.gbl... > Hello, > > I'm using visual studio .net 2k3 to work with Xml intensive integration > App. When I using XML /XSD based documents I get autocomplete feature but > not when I use Xml /Dtd based. Somebody know How work around > >...

ASP.Net
Hi, I have a few questions about ASP.Net, as I've been using it for a while but my knowledge of the "big picture" is patchy in some areas. Any help would be appreciated... - Where is the line between "native" language features (e.g. in JScript), and those features which are part of .Net (or whatever), common to all .Net languages? Or put another way, how are the .Net facilities "mapped" onto a particular language? (I'm sorry of this question is somewhat vague...) - In a closely-related matter, do any languages have issues accessing the full A...

The operation failed. An object could not be found #2
Dear All, I am having a strange problem. I have moved some mailboxes from Exchange 2003 to Exchange 2007. After that the existing outlook profile on Exchange 2003 on the user laptop was deleted and a new profile was created for Exchange 2007 on Outlook. Everything is ok except under the favourites folder in Outlook 2003 or Outlook 2007 when you click on unread mail or follow up folder you get the following error:- The operation failed. An objet could not be found. I have created the profile on Outlook 2007 and Outlook 2003 but the same problem remains. Please Help. -- Haroon Malik ...

Showing raw xml from memory in an asp.net page
Hi. I'd like to create an xml document on the fly and then display it in an asp.net page. I can use an iframe and point to a URL (which displays perfectly), but I'd not like to save the xml to a file (it will be built as I go along). I can use the <asp:xml> control, but I don't want to have to write the XSLT, I love the one I get for free within IFrame. Any suggestions? Thanks. Figured out the answer to my own question. I thought I'd post it in case anyone is interested... 1) Create a page with an IFrame on it. Set the src to a second page 2) On the second aspx pa...

Setup Failed 12-17-05
My CRM 3.0 Upgrade failed on all kinds of levels which was no surprise to me. Does anyone know where the log file is - I cleared the "failure" screen by accident. I need to analyze the specific problem(s). Thanks! Hi! document and settings\user\application data\microsoft\mscrm\logs\crm30svrsetup.log. My upgrade fails to : Cannot insert the value NULL into column 'DeletionStateCode', table 'Mepco_Oy_MSCRM.dbo.ActivityPointerBase'; column does not allow nulls. INSERT fails. This a new table that setup creates so I cannot just modify that column to accept null...

SQL Server 2000
Hello, after completing the Mainentance Plan wizard in which the Integrity Checks and Transaction Log Backup job fail I came across this http://www.mssqltips.com/tip.asp?tip=1219 mentioning of the SIMPLE Recovery mode is hindering it. Think I'm missing something...so does anyone know how to put the other dbs into FULL Recovery mode and is it ok to do? Thanks in advance. Right click on the database and select Properties then select the Options tab. You change change the recovery model here. The only difference between simple and full recovery is that simple does not...

Microsoft .Net Framework error message?
When system is booted I get a error box that pops up on the desktop screen which says. REQUIRED SYSTEM SOFTWARE NOT INSTALLED. Microsoft .NET Framework Version 2.0 is required to continue. This software is available for free download at http://www.microsoft.com/downloads/ I have all updates installed. Windows directory includes the following. C:\Windows\Microsoft.Net\Framework64\V2.0.50727\V3.0\V3.5 C:\Windows\Microsoft.Net\Framework\V2.0.50727\V3.0\V3.5 I have no clue what is going on with the error message and am very computer Literate having a Computer repair servic...

Integration Manager
I have a customer integration which runs fine the first time. If I re-run it it fails with the following message: Beginning integration... DOC 1 ERROR: Internet Information for Address 'PRIMARY' already exists; cannot insert. Integration Failed The destination edit mode is set to Insert and Update. You want to take out the your address information for the integration manager on the next reruns. There are certain fields that will work with integration manager only once. After the first run, the field is then a Key field on another table, in this case the "Address ID" fi...

EnableDocking(CBRS_ALIGN_RIGHT) failed
Hi all, if I change CBRS_ALIGN_ANY to CBRS_ALIGN_RIGHT, the code will break at statement DockControlBar(&m_wndToolBar); why? thanks int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; EnableDocking(CBRS_ALIGN_RIGHT); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndSta...

SBS 2003 SP1, CRM 3.0 and .Net updates
I updated the SBS server to .net 2.0, applied the security patches to .Net 2.0, updated to .Net 3.0. Now the Outlook 2003 cannot connect to CRM. Any ideas? ...

Net Folders #14
Does anyone have any experience with Net Folders & utilizing them to share folders where we only have internet mail accounts (i.e. we do not have an internal mail server such as MS Exchange)? I've been having problems with entries in Outlook's Calendar being multiplied--that's to say it shows up several times as if the program is replicating the entry. Microsoft has very little on troubleshooting web folders & I was wondering if anyone has experience with these. ...

Custom form
I have a custom Outlook form that is based upon the IPM.Post item. This form (saved in an exchange public folder) works fine for a while, but at some point (after entering data) the form can be saved. If you create a new form in the folder it works fine as do previously saved items until you enter that magical amount of data and it no longer will open. We have had the admin look at the settings for the folder and all he could find is a quota for the folder, which we are not even close to. Are there other settings that would stop a form from opening when it hit a certain limit? I have ne...

Problems with WMP ActiveX Control in VS.Net
Hello I am trying to embed the Windows Media Player ActiveX control in a dialog using VS.Net. When trying at associate a variable with the control, VS.Net does not give the same options as VS6, and generates a wrapper class that doesn't have any operations(making it useless). I have tried using the wrapper classes that VS6 generates but this doesn't seem to work. after DDX_Control(pDX, IDC_PLAYER, m_wndPlayer) gets executed, m_wndPlayer's hWnd is still set to null. There are no problems when using this code with VS6. Anyone with a similar problem, or know how to fix it? Thank...

Gurus for XML TextStream vs Response Stream vs XMLValidatingReader
Hi, I try retrieve an XML stream from a webapp using a post "http://webedu.its.uct.ac.za/webct/public/serve_webctdb?OPERATION=homearea_xml&DB=global&WebCT%20ID=rodgersn_its_main&AUTH=ee09aabc77ef593917a60720f167c733" and result = req.GetResponse() ReceiveStream = result.GetResponseStream() from here ..I try read the XML retrieved, but... I've tried XMLStream and XMLValidatingStream..both return "There is invalid data at the root level" Trying a std StreamReader with say .readtoend or sr.Read(read, 0, 256) in a count lo...

How to build WinCE.net application with vs.net 2005
Hi, VS.net 2005 can be used to create SmartPhone and PocketPC 2003 applications by using C++(MFC), but there is no an option to create the WinCE.net application that can be created by EVC4 before, is it possible to create WinCE.net application by using VS.net 2005? Thanks. Regards, ZhangZQ What do you mean? You can create apps in C#, VB or native (C/C++). What "other" type are you after? -Chris "ZhangZQ" <zhangzq71@hotmail.com> wrote in message news:esuZfFKNGHA.3728@tk2msftngp13.phx.gbl... > Hi, > > VS.net 2005 can be used to create SmartPhon...