You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2010/02/07 09:58:10 UTC
svn commit: r907398 -
/xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java
Author: mukulg
Date: Sun Feb 7 08:58:10 2010
New Revision: 907398
URL: http://svn.apache.org/viewvc?rev=907398&view=rev
Log:
adding support for xs:attributeGroup serialization
Modified:
xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java
Modified: xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java?rev=907398&r1=907397&r2=907398&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java Sun Feb 7 08:58:10 2010
@@ -25,6 +25,7 @@
import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
import org.apache.xerces.impl.xs.XMLSchemaLoader;
import org.apache.xerces.impl.xs.XSAttributeDecl;
+import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.impl.xs.XSElementDecl;
import org.apache.xerces.impl.xs.XSGroupDecl;
@@ -142,7 +143,8 @@
Element schemaDeclDomNode = document.createElementNS(XSD_LANGUAGE_URI,
XSD_LANGUAGE_PREFIX
- + "schema");
+ + "schema");
+
document.appendChild(schemaDeclDomNode);
// process global element declarations
@@ -165,6 +167,12 @@
(XSConstants.ATTRIBUTE_DECLARATION);
processGlobalAttrDecl(globalAttrDecls, document, schemaDeclDomNode);
+ // process global attribute group declarations
+ XSNamedMap globalAttrGroupDecls = xsModel.getComponents
+ (XSConstants.ATTRIBUTE_GROUP);
+ processGlobalAttrGroupDecl(globalAttrGroupDecls, document, schemaDeclDomNode);
+
+ // process global model group declarations
XSNamedMap globalGroupDecls = xsModel.getComponents
(XSConstants.MODEL_GROUP_DEFINITION);
processGlobalGroupDecl(globalGroupDecls, document, schemaDeclDomNode);
@@ -173,6 +181,52 @@
} // end of, transformXSModelToDOM
/*
+ * Process global attribute group declarations
+ */
+ private void processGlobalAttrGroupDecl(XSNamedMap globalAttrGpDecls,
+ Document document,
+ Element schemaDeclDomNode) {
+ // iterating global attribute group declarations in the Schema
+ for (int attrGpIdx = 0; attrGpIdx < globalAttrGpDecls.size(); attrGpIdx++) {
+ XSAttributeGroupDecl attrGpDecl = (XSAttributeGroupDecl)
+ globalAttrGpDecls.item(attrGpIdx);
+ String attrGpName = attrGpDecl.getName();
+ Element attrGpDomNode = document.createElementNS(XSD_LANGUAGE_URI,
+ XSD_LANGUAGE_PREFIX
+ + "attributeGroup");
+ attrGpDomNode.setAttributeNS(null, "name", attrGpName);
+ XSObjectList attrUses = attrGpDecl.getAttributeUses();
+ for (int attrUsesIdx = 0; attrUsesIdx < attrUses.size(); attrUsesIdx++) {
+ XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(attrUsesIdx);
+ XSAttributeDecl attrDecl = (XSAttributeDecl) attrUse.getAttrDeclaration();
+ String constraintName = null;
+ String constraintVal = null;
+ if (attrUse.getConstraintType() != XSConstants.VC_NONE) {
+ constraintName = (attrUse.getConstraintType() ==
+ XSConstants.VC_DEFAULT) ?
+ "default" : "fixed";
+ constraintVal = attrUse.getConstraintValue();
+ }
+ String requiredVal = (attrUse.getRequired() == true) ?
+ "required" : "optional";
+ addAttributeToSchemaComponent(document, attrGpDomNode,
+ attrDecl, constraintName,
+ constraintVal, requiredVal);
+ }
+
+ XSWildcard attrWildCard = attrGpDecl.getAttributeWildcard();
+ if (attrWildCard != null) {
+ addWildcardToSchemaComponent(document, attrGpDomNode,
+ (XSWildcardDecl) attrWildCard,
+ "anyAttribute");
+ }
+
+ schemaDeclDomNode.appendChild(attrGpDomNode);
+ }
+
+ } // end of, processGlobalAttrGroupDecl
+
+ /*
* Process global element declarations
*/
private void processGlobalElementDecl(XSNamedMap globalElemDecls,
@@ -184,7 +238,7 @@
XSElementDecl elemDecl = (XSElementDecl) globalElemDecls.item(elemIdx);
addElementDeclToSchemaComponent(document, schemaDeclDomNode,
elemDecl, null, null, true);
- }
+ }
} // end of, processGolabElementDecl
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org