You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2004/09/23 03:09:56 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/schema TraverseSchema.cpp TraverseSchema.hpp
cargilld 2004/09/22 18:09:56
Modified: c/src/xercesc/internal XMLScanner.cpp XMLScanner.hpp
c/src/xercesc/parsers AbstractDOMParser.cpp
AbstractDOMParser.hpp DOMBuilderImpl.cpp
SAX2XMLReaderImpl.cpp SAXParser.cpp SAXParser.hpp
c/src/xercesc/util XMLUni.cpp XMLUni.hpp
c/src/xercesc/validators/schema TraverseSchema.cpp
TraverseSchema.hpp
Log:
Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI.
Revision Changes Path
1.69 +3 -1 xml-xerces/c/src/xercesc/internal/XMLScanner.cpp
Index: XMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- XMLScanner.cpp 8 Sep 2004 13:56:14 -0000 1.68
+++ XMLScanner.cpp 23 Sep 2004 01:09:55 -0000 1.69
@@ -140,6 +140,7 @@
, fUseCachedGrammar(false)
, fLoadExternalDTD(true)
, fNormalizeData(true)
+ , fGenerateSyntheticAnnotations(false)
, fErrorCount(0)
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
@@ -218,6 +219,7 @@
, fUseCachedGrammar(false)
, fLoadExternalDTD(true)
, fNormalizeData(true)
+ , fGenerateSyntheticAnnotations(false)
, fErrorCount(0)
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
1.38 +18 -0 xml-xerces/c/src/xercesc/internal/XMLScanner.hpp
Index: XMLScanner.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.hpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- XMLScanner.hpp 8 Sep 2004 13:56:14 -0000 1.37
+++ XMLScanner.hpp 23 Sep 2004 01:09:55 -0000 1.38
@@ -16,6 +16,9 @@
/*
* $Log$
+ * Revision 1.38 2004/09/23 01:09:55 cargilld
+ * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI.
+ *
* Revision 1.37 2004/09/08 13:56:14 peiyongz
* Apache License Version 2.0
*
@@ -513,6 +516,8 @@
unsigned int getPrefixId(const XMLCh* const prefix) const;
const XMLCh* getPrefixForId(unsigned int prefId) const;
+ bool getGenerateSyntheticAnnotations() const;
+
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
@@ -606,6 +611,8 @@
void setParseSettings(XMLScanner* const refScanner);
void setStandardUriConformant(const bool newValue);
+ void setGenerateSyntheticAnnotations(const bool newValue);
+
// -----------------------------------------------------------------------
// Mutator methods
// -----------------------------------------------------------------------
@@ -957,6 +964,7 @@
bool fUseCachedGrammar;
bool fLoadExternalDTD;
bool fNormalizeData;
+ bool fGenerateSyntheticAnnotations;
int fErrorCount;
unsigned int fEntityExpansionLimit;
unsigned int fEntityExpansionCount;
@@ -1302,6 +1310,11 @@
return fElemStack.getPrefixForId(prefId);
}
+inline bool XMLScanner::getGenerateSyntheticAnnotations() const
+{
+ return fGenerateSyntheticAnnotations;
+}
+
// ---------------------------------------------------------------------------
// XMLScanner: Setter methods
// ---------------------------------------------------------------------------
@@ -1453,6 +1466,11 @@
{
fStandardUriConformant = newValue;
fReaderMgr.setStandardUriConformant(newValue);
+}
+
+inline void XMLScanner::setGenerateSyntheticAnnotations(const bool newValue)
+{
+ fGenerateSyntheticAnnotations = newValue;
}
// ---------------------------------------------------------------------------
1.67 +11 -1 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp
Index: AbstractDOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- AbstractDOMParser.cpp 21 Sep 2004 16:11:29 -0000 1.66
+++ AbstractDOMParser.cpp 23 Sep 2004 01:09:55 -0000 1.67
@@ -230,6 +230,11 @@
return fScanner->getDoNamespaces();
}
+bool AbstractDOMParser::getGenerateSyntheticAnnotations() const
+{
+ return fScanner->getGenerateSyntheticAnnotations();
+}
+
bool AbstractDOMParser::getExitOnFirstFatalError() const
{
return fScanner->getExitOnFirstFatal();
@@ -321,6 +326,11 @@
void AbstractDOMParser::setDoNamespaces(const bool newState)
{
fScanner->setDoNamespaces(newState);
+}
+
+void AbstractDOMParser::setGenerateSyntheticAnnotations(const bool newState)
+{
+ fScanner->setGenerateSyntheticAnnotations(newState);
}
void AbstractDOMParser::setExitOnFirstFatalError(const bool newState)
1.34 +26 -1 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.hpp
Index: AbstractDOMParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.hpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- AbstractDOMParser.hpp 21 Sep 2004 16:11:29 -0000 1.33
+++ AbstractDOMParser.hpp 23 Sep 2004 01:09:55 -0000 1.34
@@ -408,6 +408,19 @@
*/
bool getCreateSchemaInfo() const;
+ /** Get the 'generate synthetic validations' flag
+ *
+ * @return true, if the parser is currently configured to
+ * generate synthetic annotations, false otherwise.
+ * A synthetic XSAnnotation is created when a schema
+ * component has non-schema attributes but has no
+ * child annotations so that the non-schema attributes
+ * can be recovered under PSVI.
+ *
+ * @see #setGenerateSyntheticAnnotations
+ */
+ bool getGenerateSyntheticAnnotations() const;
+
//@}
@@ -417,6 +430,18 @@
/** @name Setter methods */
//@{
+ /** set the 'generate synthetic validations' flag
+ *
+ * @param newValue The value for specifying whether Synthetic Annotations
+ * should be generated or not.
+ * A synthetic XSAnnotation is created when a schema
+ * component has non-schema attributes but has no
+ * child annotations so that the non-schema attributes
+ * can be recovered under PSVI.
+ *
+ * @see #getGenerateSyntheticAnnotations
+ */
+ void setGenerateSyntheticAnnotations(const bool newValue);
/** Set the 'do namespaces' flag
*
1.39 +9 -1 xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp
Index: DOMBuilderImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- DOMBuilderImpl.cpp 20 Sep 2004 15:00:49 -0000 1.38
+++ DOMBuilderImpl.cpp 23 Sep 2004 01:09:55 -0000 1.39
@@ -231,6 +231,10 @@
{
setCreateSchemaInfo(state);
}
+ else if (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0)
+ {
+ getScanner()->setGenerateSyntheticAnnotations(state);
+ }
else {
throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager());
}
@@ -320,6 +324,10 @@
}
else if (XMLString::compareIString(name, XMLUni::fgXercesDOMHasPSVIInfo) == 0) {
return getCreateSchemaInfo();
+ }
+ else if (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0)
+ {
+ return getScanner()->getGenerateSyntheticAnnotations();
}
else {
throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager());
1.36 +9 -0 xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
Index: SAX2XMLReaderImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- SAX2XMLReaderImpl.cpp 8 Sep 2004 13:56:17 -0000 1.35
+++ SAX2XMLReaderImpl.cpp 23 Sep 2004 01:09:55 -0000 1.36
@@ -16,6 +16,9 @@
/*
* $Log$
+ * Revision 1.36 2004/09/23 01:09:55 cargilld
+ * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI.
+ *
* Revision 1.35 2004/09/08 13:56:17 peiyongz
* Apache License Version 2.0
*
@@ -1557,6 +1560,10 @@
{
fScanner->setStandardUriConformant(value);
}
+ else if (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0)
+ {
+ fScanner->setGenerateSyntheticAnnotations(value);
+ }
else
throw SAXNotRecognizedException("Unknown Feature", fMemoryManager);
}
@@ -1591,6 +1598,8 @@
return fScanner->getCalculateSrcOfs();
else if (XMLString::compareIString(name, XMLUni::fgXercesStandardUriConformant) == 0)
return fScanner->getStandardUriConformant();
+ else if (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0)
+ return fScanner->getGenerateSyntheticAnnotations();
else
throw SAXNotRecognizedException("Unknown Feature", fMemoryManager);
1.34 +11 -0 xml-xerces/c/src/xercesc/parsers/SAXParser.cpp
Index: SAXParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- SAXParser.cpp 8 Sep 2004 13:56:17 -0000 1.33
+++ SAXParser.cpp 23 Sep 2004 01:09:55 -0000 1.34
@@ -16,6 +16,9 @@
/*
* $Log$
+ * Revision 1.34 2004/09/23 01:09:55 cargilld
+ * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI.
+ *
* Revision 1.33 2004/09/08 13:56:17 peiyongz
* Apache License Version 2.0
*
@@ -446,6 +449,10 @@
return fScanner->getDoNamespaces();
}
+bool SAXParser::getGenerateSyntheticAnnotations() const
+{
+ return fScanner->getGenerateSyntheticAnnotations();
+}
bool SAXParser::getExitOnFirstFatalError() const
{
@@ -558,6 +565,10 @@
fScanner->setDoNamespaces(newState);
}
+void SAXParser::setGenerateSyntheticAnnotations(const bool newState)
+{
+ fScanner->setGenerateSyntheticAnnotations(newState);
+}
void SAXParser::setExitOnFirstFatalError(const bool newState)
{
1.33 +28 -0 xml-xerces/c/src/xercesc/parsers/SAXParser.hpp
Index: SAXParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.hpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- SAXParser.hpp 8 Sep 2004 13:56:18 -0000 1.32
+++ SAXParser.hpp 23 Sep 2004 01:09:55 -0000 1.33
@@ -16,6 +16,9 @@
/*
* $Log$
+ * Revision 1.33 2004/09/23 01:09:55 cargilld
+ * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI.
+ *
* Revision 1.32 2004/09/08 13:56:18 peiyongz
* Apache License Version 2.0
*
@@ -642,6 +645,19 @@
*/
unsigned int getSrcOffset() const;
+ /** Get the 'generate synthetic validations' flag
+ *
+ * @return true, if the parser is currently configured to
+ * generate synthetic annotations, false otherwise.
+ * A synthetic XSAnnotation is created when a schema
+ * component has non-schema attributes but has no
+ * child annotations so that the non-schema attributes
+ * can be recovered under PSVI.
+ *
+ * @see #setGenerateSyntheticAnnotations
+ */
+ bool getGenerateSyntheticAnnotations() const;
+
//@}
@@ -651,6 +667,18 @@
/** @name Setter methods */
//@{
+ /** set the 'generate synthetic validations' flag
+ *
+ * @param newValue The value for specifying whether Synthetic Annotations
+ * should be generated or not.
+ * A synthetic XSAnnotation is created when a schema
+ * component has non-schema attributes but has no
+ * child annotations.
+ *
+ * @see #getGenerateSyntheticAnnotations
+ */
+ void setGenerateSyntheticAnnotations(const bool newValue);
+
/**
* This method allows users to enable or disable the parser's
* namespace processing. When set to true, parser starts enforcing
1.44 +17 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp
Index: XMLUni.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- XMLUni.cpp 20 Sep 2004 15:00:50 -0000 1.43
+++ XMLUni.cpp 23 Sep 2004 01:09:56 -0000 1.44
@@ -30,6 +30,7 @@
// ---------------------------------------------------------------------------
// XMLUni: Static data
// ---------------------------------------------------------------------------
+
const XMLCh XMLUni::fgAnyString[] =
{
chLatin_A, chLatin_N, chLatin_Y, chNull
@@ -1092,6 +1093,21 @@
, chForwardSlash, chLatin_d, chLatin_o, chLatin_m, chDash, chLatin_h
, chLatin_a, chLatin_s, chDash, chLatin_p, chLatin_s, chLatin_v, chLatin_i
, chDash, chLatin_i, chLatin_n, chLatin_f, chLatin_o, chNull
+};
+
+//Xerces: http://apache.org/xml/features/generate-synthetic-annotations
+const XMLCh XMLUni::fgXercesGenerateSyntheticAnnotations[] =
+{
+ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash
+ , chForwardSlash, chLatin_a, chLatin_p, chLatin_a, chLatin_c, chLatin_h
+ , chLatin_e, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash
+ , chLatin_x, chLatin_m, chLatin_l, chForwardSlash, chLatin_f, chLatin_e
+ , chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chLatin_s
+ , chForwardSlash, chLatin_g, chLatin_e, chLatin_n, chLatin_e, chLatin_r
+ , chLatin_a, chLatin_t, chLatin_e, chDash, chLatin_s, chLatin_y, chLatin_n
+ , chLatin_t, chLatin_h, chLatin_e, chLatin_t, chLatin_i, chLatin_c, chDash
+ , chLatin_a, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t
+ , chLatin_i, chLatin_o, chLatin_n, chLatin_s, chNull
};
//Property
1.39 +2 -1 xml-xerces/c/src/xercesc/util/XMLUni.hpp
Index: XMLUni.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- XMLUni.hpp 20 Sep 2004 15:00:51 -0000 1.38
+++ XMLUni.hpp 23 Sep 2004 01:09:56 -0000 1.39
@@ -220,6 +220,7 @@
static const XMLCh fgXercesCalculateSrcOfs[];
static const XMLCh fgXercesStandardUriConformant[];
static const XMLCh fgXercesDOMHasPSVIInfo[];
+ static const XMLCh fgXercesGenerateSyntheticAnnotations[];
// SAX2 features/properties names
static const XMLCh fgSAX2CoreValidation[];
1.116 +306 -21 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- TraverseSchema.cpp 8 Sep 2004 13:56:57 -0000 1.115
+++ TraverseSchema.cpp 23 Sep 2004 01:09:56 -0000 1.116
@@ -141,6 +141,28 @@
SchemaSymbols::fgELT_KEYREF
};
+const XMLCh fgAnnotation[] =
+{
+ chLatin_a, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t
+ , chLatin_i, chLatin_o, chLatin_n, chNull
+};
+
+const XMLCh fgDocumentation[] =
+{
+ chLatin_d, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e
+ , chLatin_n, chLatin_t, chLatin_a, chLatin_t
+ , chLatin_i, chLatin_o, chLatin_n, chNull
+};
+
+const XMLCh fgSynthetic_Annotation[] =
+{
+ chLatin_S, chLatin_y, chLatin_n, chLatin_t, chLatin_h, chLatin_e, chLatin_t
+ , chLatin_i, chLatin_c, chUnderscore
+ , chLatin_A, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t
+ , chLatin_i, chLatin_o, chLatin_n, chNull
+};
+
+
// Flags for global declaration
enum {
ENUM_ELT_SIMPLETYPE,
@@ -535,7 +557,7 @@
// Check attributes
// -----------------------------------------------------------------------
fAttributeCheck.checkAttributes(
- elem, GeneralAttributeCheck::E_Include, this, true);
+ elem, GeneralAttributeCheck::E_Include, this, true, fNonXSAttList);
// -----------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -545,6 +567,11 @@
if (fAnnotation)
fSchemaGrammar->addAnnotation(fAnnotation);
+ else if (fScanner->getGenerateSyntheticAnnotations() && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ fSchemaGrammar->addAnnotation(fAnnotation);
+ }
// -----------------------------------------------------------------------
// Get 'schemaLocation' attribute
@@ -683,7 +710,7 @@
// Check attributes
// -----------------------------------------------------------------------
fAttributeCheck.checkAttributes(
- elem, GeneralAttributeCheck::E_Import, this, true);
+ elem, GeneralAttributeCheck::E_Import, this, true, fNonXSAttList);
// -----------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -693,7 +720,11 @@
if (fAnnotation)
fSchemaGrammar->addAnnotation(fAnnotation);
-
+ else if (fScanner->getGenerateSyntheticAnnotations() && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ fSchemaGrammar->addAnnotation(fAnnotation);
+ }
// -----------------------------------------------------------------------
// Handle 'namespace' attribute
// -----------------------------------------------------------------------
@@ -955,7 +986,11 @@
// -----------------------------------------------------------------------
// Process contents
// -----------------------------------------------------------------------
- DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
ContentSpecNode* left = 0;
ContentSpecNode* right = 0;
@@ -1143,9 +1178,12 @@
// annotation?,(list|restriction|union)
DOMElement* content= checkContent(
- childElem, XUtil::getFirstChildElement(childElem), false);
+ childElem, XUtil::getFirstChildElement(childElem), false);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(childElem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
-
if (content == 0) {
reportSchemaError(childElem, XMLUni::fgXMLErrDomain, XMLErrs::EmptySimpleTypeContent);
@@ -1308,7 +1346,12 @@
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration and get next child
// ------------------------------------------------------------------
- DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
// ------------------------------------------------------------------
@@ -1480,9 +1523,12 @@
// ------------------------------------------------------------------
// Check for annotations
// ------------------------------------------------------------------
- DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
-
// ------------------------------------------------------------------
// Process contents of global groups
// ------------------------------------------------------------------
@@ -1667,6 +1713,10 @@
// Check for annotations
DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
// Process contents of global attributeGroups
@@ -1808,6 +1858,10 @@
// ------------------------------------------------------------------
if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0) {
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::OnlyAnnotationExpected);
+ }
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
}
Janitor<XSAnnotation> janAnnot(fAnnotation);
@@ -1979,7 +2033,11 @@
// -----------------------------------------------------------------------
// Process contents
// -----------------------------------------------------------------------
- DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
if (child == 0) {
@@ -2165,6 +2223,12 @@
processAttributeDeclRef(elem, typeInfo, ref, useVal, defaultVal, fixedVal);
return;
}
+
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ janAnnot.reset(fAnnotation);
+ }
// processing 'name'
if (!XMLString::isValidNCName(name)
@@ -2490,7 +2554,11 @@
fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
// check annotation
- const DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ const DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
// Create element decl
@@ -2732,7 +2800,11 @@
checkContent(elem, XUtil::getFirstChildElement(elem), true);
if (fAnnotation)
fSchemaGrammar->putAnnotation(decl, fAnnotation);
-
+ else if (fScanner->getGenerateSyntheticAnnotations() && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ fSchemaGrammar->putAnnotation(decl, fAnnotation);
+ }
return name;
}
@@ -2817,7 +2889,10 @@
if (!baseTypeName || !*baseTypeName) { // must 'see' <simpleType>
content = checkContent(rootElem, XUtil::getFirstChildElement(contentElem), false);
-
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentElem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -2849,7 +2924,10 @@
baseValidator = findDTValidator(contentElem, typeName, baseTypeName, SchemaSymbols::XSD_LIST);
content = checkContent(rootElem, XUtil::getFirstChildElement(contentElem), true);
-
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentElem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -2924,7 +3002,10 @@
if (!baseTypeName || !*baseTypeName) { // must 'see' <simpleType>
content = checkContent(rootElem, XUtil::getFirstChildElement(contentElem), false);
-
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentElem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -2957,6 +3038,10 @@
baseValidator = findDTValidator(contentElem, typeName, baseTypeName, SchemaSymbols::XSD_RESTRICTION);
content = checkContent(rootElem, XUtil::getFirstChildElement(contentElem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentElem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3013,7 +3098,10 @@
}
if (XMLString::equals(facetName, SchemaSymbols::fgELT_ENUMERATION)) {
-
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(content, fNonXSAttList);
+ }
if (fAnnotation) {
if (janEnumAnnot.isDataNull())
janEnumAnnot.reset(fAnnotation);
@@ -3050,7 +3138,10 @@
}
}
else if (XMLString::equals(facetName, SchemaSymbols::fgELT_PATTERN)) {
-
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(content, fNonXSAttList);
+ }
if (fAnnotation) {
if (janPatternAnnot.isDataNull())
janPatternAnnot.reset(fAnnotation);
@@ -3091,7 +3182,10 @@
const XMLCh* facetStr = fStringPool->getValueForId(fStringPool->addOrFind(facetName));
KVStringPair* kv = new (fGrammarPoolMemoryManager) KVStringPair(facetStr, attValue, fGrammarPoolMemoryManager);
-
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(content, fNonXSAttList);
+ }
if (fAnnotation)
fSchemaGrammar->putAnnotation(kv, fAnnotation);
@@ -3188,6 +3282,10 @@
}
content = checkContent(rootElem, XUtil::getFirstChildElement(contentElem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentElem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3199,6 +3297,10 @@
else { // must 'see' <simpleType>
content = checkContent(rootElem, XUtil::getFirstChildElement(contentElem), false);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentElem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3321,6 +3423,10 @@
// Process annotation if any
// -----------------------------------------------------------------------
DOMElement* simpleContent = checkContent(contentDecl, XUtil::getFirstChildElement(contentDecl), false);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentDecl, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3437,6 +3543,10 @@
// -----------------------------------------------------------------------
//Skip over any annotations in the restriction or extension elements
DOMElement* content = checkContent(simpleContent, XUtil::getFirstChildElement(simpleContent), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(simpleContent, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3725,6 +3835,10 @@
typeInfo->setBaseDatatypeValidator(0);
DOMElement* complexContent = checkContent(contentDecl,XUtil::getFirstChildElement(contentDecl),false);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(contentDecl, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3797,7 +3911,7 @@
// Process the content of the derivation
// -----------------------------------------------------------------------
//Skip over any annotations in the restriction or extension elements
- DOMElement* content = checkContent(complexContent, XUtil::getFirstChildElement(complexContent), true);
+ DOMElement* content = checkContent(complexContent, XUtil::getFirstChildElement(complexContent), true);
if (fAnnotation)
{
if (janAnnot->isDataNull())
@@ -3837,9 +3951,12 @@
// ------------------------------------------------------------------
if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0) {
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::AnyAttributeContentError);
+ }
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
}
Janitor<XSAnnotation> janAnnot(fAnnotation);
-
// ------------------------------------------------------------------
// Get attributes
// ------------------------------------------------------------------
@@ -4156,6 +4273,10 @@
// First, handle any ANNOTATION declaration
// ------------------------------------------------------------------
DOMElement* elem = checkContent(icElem, XUtil::getFirstChildElement(icElem), false);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(icElem, fNonXSAttList);
+ }
Janitor<XSAnnotation> janAnnot(fAnnotation);
// ------------------------------------------------------------------
@@ -4177,6 +4298,10 @@
elem, GeneralAttributeCheck::E_Selector, this, false, fNonXSAttList
);
checkContent(icElem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot.isDataNull())
@@ -4257,6 +4382,10 @@
elem, GeneralAttributeCheck::E_Field, this, false, fNonXSAttList
);
checkContent(icElem, XUtil::getFirstChildElement(elem), true);
+ if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
+ {
+ fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
+ }
if (fAnnotation)
{
if (janAnnot.isDataNull())
@@ -4363,6 +4492,7 @@
void TraverseSchema::processChildren(const DOMElement* const root) {
+ bool sawAnnotation = false;
// process <redefine>, <include> and <import> info items.
DOMElement* child = XUtil::getFirstChildElement(root);
@@ -4375,6 +4505,7 @@
traverseAnnotationDecl(
child, fSchemaInfo->getNonXSAttList(), true)
);
+ sawAnnotation = true;
}
else if (XMLString::equals(name, SchemaSymbols::fgELT_INCLUDE)) {
traverseInclude(child);
@@ -4410,6 +4541,7 @@
traverseAnnotationDecl(
child, fSchemaInfo->getNonXSAttList(), true)
);
+ sawAnnotation = true;
}
else if (XMLString::equals(name, SchemaSymbols::fgELT_SIMPLETYPE)) {
@@ -4522,6 +4654,15 @@
}
} // for each child node
+
+ if (fSchemaInfo->getNonXSAttList()->size() && !sawAnnotation)
+ {
+ // synthesize a global annotation here.
+ fSchemaGrammar->addAnnotation(
+ generateSyntheticAnnotation(root, fSchemaInfo->getNonXSAttList())
+ );
+ }
+
// Handle recursing elements - if any
ValueVectorOf<const DOMElement*>* recursingAnonTypes = fSchemaInfo->getRecursingAnonTypes();
@@ -4784,6 +4925,8 @@
DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
Janitor<XSAnnotation> janAnnot(fAnnotation);
+ // do not generate synthetic annotation for element reference...
+
if (content != 0)
reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::NoContentForRef, SchemaSymbols::fgELT_ELEMENT);
@@ -8584,6 +8727,148 @@
nextCh = *++srcVal;
}
+}
+
+XSAnnotation* TraverseSchema::generateSyntheticAnnotation(const DOMElement* const elem
+ , ValueVectorOf<DOMNode*>* nonXSAttList)
+{
+ const XMLCh* prefix = elem->getPrefix();
+ ValueVectorOf<unsigned int>* listOfURIs = new (fMemoryManager) ValueVectorOf<unsigned int>(16, fMemoryManager);
+ bool sawXMLNS = false;
+
+ fBuffer.reset();
+ fBuffer.append(chOpenAngle);
+ if (prefix)
+ {
+ fBuffer.append(prefix);
+ fBuffer.append(chColon);
+ }
+ fBuffer.append(fgAnnotation);
+
+ // next is the nonXSAttList names & values
+ unsigned int nonXSAttSize = nonXSAttList->size();
+
+ for (unsigned int i=0; i<nonXSAttSize; i++)
+ {
+ DOMNode* attNode = nonXSAttList->elementAt(i);
+
+ fBuffer.append(chSpace);
+ fBuffer.append(attNode->getNodeName());
+ fBuffer.append(chEqual);
+ fBuffer.append(chDoubleQuote);
+ processAttValue(attNode->getNodeValue(), fBuffer);
+ fBuffer.append(chDoubleQuote);
+ }
+
+ // next is the namespaces on the elem
+ DOMNamedNodeMap* eltAttrs = elem->getAttributes();
+ int attrCount = eltAttrs->getLength();
+
+ for (int j = 0; j < attrCount; j++)
+ {
+ DOMNode* attribute = eltAttrs->item(j);
+ const XMLCh* attName = attribute->getNodeName();
+
+ if (XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
+ {
+ fBuffer.append(chSpace);
+ fBuffer.append(attName);
+ fBuffer.append(chEqual);
+ fBuffer.append(chDoubleQuote);
+ processAttValue(attribute->getNodeValue(), fBuffer);
+ fBuffer.append(chDoubleQuote);
+
+ int offsetIndex = XMLString::indexOf(attName, chColon);
+ int prefixId = fNamespaceScope->getNamespaceForPrefix(attName + offsetIndex + 1, fSchemaInfo->getNamespaceScopeLevel());
+ if (prefixId)
+ listOfURIs->addElement(prefixId);
+ }
+ else if (XMLString::equals(attName, XMLUni::fgXMLNSString))
+ {
+ fBuffer.append(chSpace);
+ fBuffer.append(attName);
+ fBuffer.append(chEqual);
+ fBuffer.append(chDoubleQuote);
+ processAttValue(attribute->getNodeValue(), fBuffer);
+ fBuffer.append(chDoubleQuote);
+ sawXMLNS = true;
+ }
+ }
+
+ // next is the namespaces on the fSchemaRoot
+ eltAttrs = fSchemaInfo->getRoot()->getAttributes();
+ attrCount = eltAttrs->getLength();
+
+ for (int j = 0; j < attrCount; j++)
+ {
+ DOMNode* attribute = eltAttrs->item(j);
+ if (!attribute) {
+ break;
+ }
+ const XMLCh* attName = attribute->getNodeName();
+
+ if (XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
+ {
+ int offsetIndex = XMLString::indexOf(attName, chColon);
+ int prefixId = fNamespaceScope->getNamespaceForPrefix(attName + offsetIndex + 1, fSchemaInfo->getNamespaceScopeLevel());
+
+ if (!listOfURIs->containsElement(prefixId)) {
+ fBuffer.append(chSpace);
+ fBuffer.append(attName);
+ fBuffer.append(chEqual);
+ fBuffer.append(chDoubleQuote);
+ processAttValue(attribute->getNodeValue(), fBuffer);
+ fBuffer.append(chDoubleQuote);
+ }
+ }
+ else if (!sawXMLNS && XMLString::equals(attName, XMLUni::fgXMLNSString))
+ {
+ fBuffer.append(chSpace);
+ fBuffer.append(attName);
+ fBuffer.append(chEqual);
+ fBuffer.append(chDoubleQuote);
+ processAttValue(attribute->getNodeValue(), fBuffer);
+ fBuffer.append(chDoubleQuote);
+ }
+ }
+ delete listOfURIs;
+
+ fBuffer.append(chCloseAngle);
+ fBuffer.append(chLF);
+ fBuffer.append(chOpenAngle);
+ if (prefix)
+ {
+ fBuffer.append(prefix);
+ fBuffer.append(chColon);
+ }
+ fBuffer.append(fgDocumentation);
+ fBuffer.append(chCloseAngle);
+ fBuffer.append(fgSynthetic_Annotation);
+ fBuffer.append(chOpenAngle);
+ fBuffer.append(chForwardSlash);
+ if (prefix)
+ {
+ fBuffer.append(prefix);
+ fBuffer.append(chColon);
+ }
+ fBuffer.append(fgDocumentation);
+ fBuffer.append(chCloseAngle);
+ fBuffer.append(chLF);
+ fBuffer.append(chOpenAngle);
+ fBuffer.append(chForwardSlash);
+ if (prefix)
+ {
+ fBuffer.append(prefix);
+ fBuffer.append(chColon);
+ }
+ fBuffer.append(fgAnnotation);
+ fBuffer.append(chCloseAngle);
+
+ XSAnnotation* annot = new (fGrammarPoolMemoryManager) XSAnnotation(fBuffer.getRawBuffer(), fGrammarPoolMemoryManager);
+ annot->setLineCol( ((XSDElementNSImpl*)elem)->getLineNo()
+ , ((XSDElementNSImpl*)elem)->getColumnNo() );
+ annot->setSystemId(fSchemaInfo->getCurrentSchemaURL());
+ return annot;
}
XERCES_CPP_NAMESPACE_END
1.36 +4 -1 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- TraverseSchema.hpp 8 Sep 2004 13:56:57 -0000 1.35
+++ TraverseSchema.hpp 23 Sep 2004 01:09:56 -0000 1.36
@@ -683,6 +683,9 @@
void processAttValue(const XMLCh* const attVal, XMLBuffer& aBuf);
+ // routine to generate synthetic annotations
+ XSAnnotation* generateSyntheticAnnotation(const DOMElement* const elem
+ , ValueVectorOf<DOMNode*>* nonXSAttList);
// -----------------------------------------------------------------------
// Private constants
// -----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org