You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by bo...@apache.org on 2009/11/18 15:20:12 UTC

svn commit: r881787 - in /xerces/c/trunk: src/xercesc/internal/ tests/src/XSTSHarness/regression/ tests/src/XSTSHarness/regression/XERCESC-1263/

Author: borisk
Date: Wed Nov 18 14:20:12 2009
New Revision: 881787

URL: http://svn.apache.org/viewvc?rev=881787&view=rev
Log:
Try to switch to the XML Schema mode if we see xsi:type or xsi:nill 
(XERCESC-1263).

Added:
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xml
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd   (with props)
Modified:
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
    xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp?rev=881787&r1=881786&r2=881787&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp Wed Nov 18 14:20:12 2009
@@ -19,7 +19,6 @@
  * $Id$
  */
 
-
 // ---------------------------------------------------------------------------
 //  This file holds some of the grunt work methods of IGXMLScanner.cpp to keep
 //  it a little more readable.
@@ -171,7 +170,7 @@
         //  boolean flag that lets us quickly below know which we are dealing
         //  with.
         const bool isNSAttr = (uriId == fEmptyNamespaceId)?
-                                XMLString::equals(suffPtr, XMLUni::fgXMLNSString) : 
+                                XMLString::equals(suffPtr, XMLUni::fgXMLNSString) :
                                 (uriId == fXMLNSNamespaceId || XMLString::equals(getURIText(uriId), SchemaSymbols::fgURI_XSI));
 
 
@@ -990,7 +989,7 @@
         //  Get the next character from the source. We have to watch for
         //  escaped characters (which are indicated by a 0xFFFF value followed
         //  by the char that was escaped.)
-        while ((nextCh = *srcPtr++)!=0) 
+        while ((nextCh = *srcPtr++)!=0)
         {
             switch(nextCh)
             {
@@ -1642,9 +1641,34 @@
                 else if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCATION))
                     resolveSchemaGrammar(valuePtr, XMLUni::fgZeroLenString);
 
+                if ((!fValidator || !fValidator->handlesSchema()) &&
+                    (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE) ||
+                     XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL)))
+                {
+                  // If we are in the DTD mode, try to switch to the Schema
+                  // mode. For that we need to find any XML Schema grammar
+                  // that we can switch to. Such a grammar can only come
+                  // from the cache (if it came from the schemaLocation
+                  // attribute, we would be in the Schema mode already).
+                  //
+                  XMLGrammarPool* pool = fGrammarResolver->getGrammarPool ();
+                  RefHashTableOfEnumerator<Grammar> i = pool->getGrammarEnumerator ();
+
+                  while (i.hasMoreElements ())
+                  {
+                    Grammar& gr (i.nextElement ());
+
+                    if (gr.getGrammarType () == Grammar::SchemaGrammarType)
+                    {
+                      switchGrammar (gr.getTargetNamespace ());
+                      break;
+                    }
+                  }
+                }
+
                 if( fValidator && fValidator->handlesSchema() )
                 {
-                    if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) 
+                    if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE))
                     {
                         // normalize the attribute according to schema whitespace facet
                         DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_QNAME);
@@ -3223,7 +3247,7 @@
         ContentSpecNode::NodeTypes type = cv->getLeafTypeAt(i);
         if ((type & 0x0f) == ContentSpecNode::Any ||
             (type & 0x0f) == ContentSpecNode::Any_Other ||
-            (type & 0x0f) == ContentSpecNode::Any_NS) 
+            (type & 0x0f) == ContentSpecNode::Any_NS)
         {
             if (type == ContentSpecNode::Any_Skip ||
                 type == ContentSpecNode::Any_NS_Skip ||

Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xml
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xml?rev=881787&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xml (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xml Wed Nov 18 14:20:12 2009
@@ -0,0 +1,2 @@
+<paramInstance xmlns="http://www.temp.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:type="ConcreteParamInstance" name="param1" />

Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd?rev=881787&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd Wed Nov 18 14:20:12 2009
@@ -0,0 +1,19 @@
+<xsd:schema targetNamespace="http://www.temp.org" xmlns:tmp="http://www.temp.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+   <!--
+      Define a 'paramInstance' element
+      NOTE: We use an abstract base to allow for extension
+      -->
+   <xsd:complexType name="ParamInstanceType" abstract="true" />
+   <xsd:element name="paramInstance" type="tmp:ParamInstanceType" />
+   <!--
+      Specifying a concrete type
+     -->
+   <xsd:complexType name="ConcreteParamInstance">
+      <xsd:complexContent>
+         <xsd:extension base="tmp:ParamInstanceType">
+            <xsd:attribute name="name" type="xsd:string" use="required" />
+         </xsd:extension>
+      </xsd:complexContent>
+   </xsd:complexType>
+   
+</xsd:schema>

Propchange: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1263/test.xsd
------------------------------------------------------------------------------
    svn:keywords = 

Modified: xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet?rev=881787&r1=881786&r2=881787&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet Wed Nov 18 14:20:12 2009
@@ -289,6 +289,23 @@
 			<current status="accepted" date="2008-02-13"/>
 		</instanceTest>
 	</testGroup>
+	<testGroup name="XERCESC-1263">
+		<annotation>
+			<documentation>Pre-loaded grammar and xsi:type in the root element</documentation>
+		</annotation>
+		<documentationReference xlink:href="https://issues.apache.org/jira/browse/XERCESC-1263"/>
+		<schemaTest name="XERCESC-1263-1">
+			<schemaDocument xlink:href="./XERCESC-1263/test.xsd"/>
+			<expected validity="valid"/>
+			<current status="accepted" date="2009-11-18"/>
+		</schemaTest>
+		<instanceTest name="XERCESC-1263-2">
+		        <schemaDocument xlink:href="./XERCESC-1263/test.xsd"/>
+			<instanceDocument xlink:href="./XERCESC-1263/test.xml"/>
+			<expected validity="valid"/>
+			<current status="accepted" date="2009-11-18"/>
+		</instanceTest>
+	</testGroup>
 	<testGroup name="XERCESC-1281">
 		<annotation>
 			<documentation>Regular expressions in schema should allow unescaped '-'</documentation>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org