Examples of XSWildcard


Examples of org.apache.xerces.xs.XSWildcard

/*  910 */     return marshalled;
/*      */   }
/*      */
/*      */   private boolean marshalWildcard(XSParticle particle, boolean declareNs)
/*      */   {
/*  915 */     XSWildcard wildcard = (XSWildcard)particle.getTerm();
/*  916 */     Object o = this.stack.peek();
/*  917 */     AbstractMarshaller.ClassMapping mapping = getClassMapping(o.getClass());
/*  918 */     if (mapping == null)
/*      */     {
/*  921 */       QName autoType = SimpleTypeBindings.typeQName(o.getClass());
/*  922 */       if (autoType != null)
/*      */       {
/*  924 */         String marshalled = SimpleTypeBindings.marshal(autoType.getLocalPart(), o, null);
/*  925 */         this.content.characters(marshalled.toCharArray(), 0, marshalled.length());
/*  926 */         return true;
/*      */       }
/*      */
/*  930 */       if (this.ignoreUnresolvedWildcard)
/*      */       {
/*  932 */         this.log.warn("Failed to marshal wildcard. Class mapping not found for " + o.getClass() + "@" + o.hashCode() + ": " + o);
/*      */
/*  938 */         return true;
/*      */       }
/*      */
/*  942 */       throw new IllegalStateException("Failed to marshal wildcard. Class mapping not found for " + o.getClass() + "@" + o.hashCode() + ": " + o);
/*      */     }
/*      */
/*  952 */     GenericObjectModelProvider parentProvider = this.provider;
/*  953 */     Object parentRoot = this.root;
/*  954 */     AbstractMarshaller.Stack parentStack = this.stack;
/*  955 */     XSModel parentModel = this.model;
/*      */
/*  957 */     this.root = o;
/*  958 */     this.stack = new AbstractMarshaller.StackImpl();
/*  959 */     this.model = (mapping.schemaUrl == null ? this.model : Util.loadSchema(mapping.schemaUrl, this.schemaResolver));
/*  960 */     if (mapping.provider != null)
/*      */     {
/*  962 */       this.provider = mapping.provider;
/*      */     }
/*      */     boolean marshalled;
/*  966 */     if (mapping.elementName != null)
/*      */     {
/*  968 */       XSElementDeclaration elDec = this.model.getElementDeclaration(mapping.elementName.getLocalPart(), mapping.elementName.getNamespaceURI());
/*      */
/*  972 */       if (elDec == null)
/*      */       {
/*  974 */         throw new JBossXBRuntimeException("Element " + mapping.elementName + " is not declared in the schema.");
/*      */       }
/*      */
/*  977 */       Object elementValue = this.provider.getRoot(this.root, null, elDec.getNamespace(), elDec.getName());
/*  978 */       marshalled = marshalElementOccurence(elDec.getNamespace(), elDec.getName(), elDec.getTypeDefinition(), elementValue, elDec.getNillable(), particle.getMinOccurs() == 0, declareNs);
/*      */     }
/*      */     else
/*      */     {
/*      */       boolean marshalled;
/*  987 */       if (mapping.typeName != null)
/*      */       {
/*  989 */         XSTypeDefinition typeDef = this.model.getTypeDefinition(mapping.typeName.getLocalPart(), mapping.typeName.getNamespaceURI());
/*      */
/*  993 */         if (typeDef == null)
/*      */         {
/*  995 */           List typeNames = new ArrayList();
/*  996 */           XSNamedMap types = this.model.getComponents(3);
/*  997 */           for (int i = 0; i < types.getLength(); i++)
/*      */           {
/*  999 */             XSObject type = types.item(i);
/* 1000 */             if ("http://www.w3.org/2001/XMLSchema".equals(type.getNamespace()))
/*      */               continue;
/* 1002 */             typeNames.add(new QName(type.getNamespace(), type.getName()));
/*      */           }
/*      */
/* 1005 */           throw new JBossXBRuntimeException("Type " + mapping.typeName + " is not defined in the schema." + " Defined types are: " + typeNames);
/*      */         }
/*      */
/* 1012 */         Object elementValue = this.provider.getRoot(this.root, null, wildcard.getNamespace(), wildcard.getName());
/* 1013 */         marshalled = marshalElementOccurence(wildcard.getNamespace(), wildcard.getName(), typeDef, elementValue, true, particle.getMinOccurs() == 0, declareNs);
/*      */       }
/*      */       else
/*      */       {
/* 1025 */         throw new JBossXBRuntimeException("Class mapping for " + mapping.cls + " is associated with neither global element name nor global type name.");
/*      */       }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.