/* */
/* */ private void marshalComplexType(QName elementQName, TypeBinding type, boolean declareNs, boolean declareXsiType)
/* */ {
/* 495 */ Collection attrBindings = type.getAttributes();
/* 496 */ int attrsTotal = (declareNs) || (declareXsiType) ? this.nsRegistry.size() + attrBindings.size() + 1 : attrBindings.size();
/* 497 */ MarshallingContextImpl.access$202(this.ctx, attrsTotal > 0 ? new AttributesImpl(attrsTotal) : null);
/* */
/* 499 */ if ((declareNs) && (this.nsRegistry.size() > 0))
/* */ {
/* 501 */ declareNs(this.ctx.attrs);
/* */ }
/* */
/* 504 */ String generatedPrefix = null;
/* 505 */ if (declareXsiType)
/* */ {
/* 507 */ generatedPrefix = declareXsiType(type.getQName(), this.ctx.attrs);
/* 508 */ if (generatedPrefix != null)
/* */ {
/* 510 */ String typeNsWithGeneratedPrefix = type.getQName().getNamespaceURI();
/* 511 */ declareNs(this.ctx.attrs, generatedPrefix, typeNsWithGeneratedPrefix);
/* 512 */ declareNamespace(generatedPrefix, typeNsWithGeneratedPrefix);
/* */ }
/* */ }
/* */
/* 516 */ String elementNs = elementQName.getNamespaceURI();
/* 517 */ String elementLocal = elementQName.getLocalPart();
/* */
/* 519 */ String prefix = getPrefix(elementNs);
/* 520 */ boolean genPrefix = (prefix == null) && (elementNs != null) && (elementNs.length() > 0);
/* 521 */ if (genPrefix)
/* */ {
/* 524 */ prefix = "ns_" + elementLocal;
/* 525 */ declareNamespace(prefix, elementNs);
/* 526 */ if (this.ctx.attrs == null)
/* */ {
/* 528 */ MarshallingContextImpl.access$202(this.ctx, new AttributesImpl(1));
/* */ }
/* 530 */ declareNs(this.ctx.attrs, prefix, elementNs);
/* */ }
/* */
/* 533 */ if (!attrBindings.isEmpty())
/* */ {
/* 535 */ for (Iterator i = attrBindings.iterator(); i.hasNext(); )
/* */ {
/* 537 */ AttributeBinding attrBinding = (AttributeBinding)i.next();
/* 538 */ QName attrQName = attrBinding.getQName();
/* */
/* 540 */ if (Constants.QNAME_XMIME_CONTENTTYPE.equals(attrQName))
/* */ {
/* */ continue;
/* */ }
/* */
/* 545 */ MarshallingContextImpl.access$302(this.ctx, attrBinding);
/* 546 */ AttributeMarshaller marshaller = attrBinding.getMarshaller();
/* 547 */ String marshalledAttr = marshaller.marshal(this.ctx);
/* */
/* 549 */ if (marshalledAttr != null)
/* */ {
/* 551 */ if (this.ctx.attrs == null)
/* */ {
/* 553 */ MarshallingContextImpl.access$202(this.ctx, new AttributesImpl(5));
/* */ }
/* */
/* 556 */ String attrNs = attrQName.getNamespaceURI();
/* 557 */ String attrLocal = attrQName.getLocalPart();
/* 558 */ String attrPrefix = null;
/* 559 */ if (attrNs != null)
/* */ {
/* 561 */ attrPrefix = getPrefix(attrNs);
/* 562 */ if ((attrPrefix == null) && (attrNs != null) && (attrNs.length() > 0))
/* */ {
/* 564 */ attrPrefix = "ns_" + attrLocal;
/* 565 */ declareNs(this.ctx.attrs, attrPrefix, attrNs);
/* */ }
/* */ }
/* */
/* 569 */ String prefixedName = prefixLocalName(attrPrefix, attrLocal);
/* 570 */ this.ctx.attrs.add(attrNs, attrLocal, prefixedName, "CDATA", marshalledAttr);
/* */ }
/* */ }
/* 573 */ MarshallingContextImpl.access$302(this.ctx, null);
/* */ }
/* */
/* 576 */ String characters = null;
/* 577 */ TypeBinding simpleType = type.getSimpleType();
/* 578 */ if ((simpleType != null) && (!Constants.QNAME_ANYTYPE.equals(type.getQName())))
/* */ {
/* 580 */ String fieldName = this.ctx.getSimpleContentProperty();
/* 581 */ CharactersMetaData charactersMetaData = type.getCharactersMetaData();
/* 582 */ PropertyMetaData propertyMetaData = charactersMetaData == null ? null : charactersMetaData.getProperty();
/* 583 */ if (propertyMetaData != null)
/* */ {
/* 585 */ fieldName = propertyMetaData.getName();
/* */ }
/* */
/* 588 */ if (fieldName != null)
/* */ {
/* 590 */ boolean ignoreUnresolvedFieldOrClass = type.getSchemaBinding().isIgnoreUnresolvedFieldOrClass();
/* 591 */ Object o = this.stack.peek();
/* 592 */ Object value = getElementValue(o, fieldName, ignoreUnresolvedFieldOrClass);
/* 593 */ if (value != null)
/* */ {
/* 595 */ String typeName = simpleType.getQName().getLocalPart();
/* 596 */ if ((this.ctx.attrs == null) && (("QName".equals(typeName)) || ("NOTATION".equals(typeName)) || ((simpleType.getItemType() != null) && (("QName".equals(simpleType.getItemType().getQName().getLocalPart())) || ("NOTATION".equals(simpleType.getItemType().getQName().getLocalPart()))))))
/* */ {
/* 605 */ MarshallingContextImpl.access$202(this.ctx, new AttributesImpl(5));
/* */ }
/* */
/* 608 */ characters = marshalCharacters(elementNs, prefix, simpleType, value);
/* */ }
/* */ }