bool CBoolDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const { if (GetParentType() && GetParentType()->GetDataMember() && GetParentType()->GetDataMember()->Attlist()) { return false; } out << ">"; const CBoolDataValue *val = GetDataMember() ? dynamic_cast<const CBoolDataValue*>(GetDataMember()->GetDefault()) : 0; PrintASNNewLine(out,indent++) << "<xs:complexType>"; PrintASNNewLine(out,indent++) << "<xs:attribute name=\"value\" use="; if (val) { out << "\"optional\" default="; if (val->GetValue()) { out << "\"true\""; } else { out << "\"false\""; } } else { out << "\"required\""; } out << ">"; PrintASNNewLine(out,indent++) << "<xs:simpleType>"; PrintASNNewLine(out,indent++) << "<xs:restriction base=\"xs:string\">"; PrintASNNewLine(out,indent) << "<xs:enumeration value=\"true\"/>"; PrintASNNewLine(out,indent) << "<xs:enumeration value=\"false\"/>"; PrintASNNewLine(out,--indent) << "</xs:restriction>"; PrintASNNewLine(out,--indent) << "</xs:simpleType>"; PrintASNNewLine(out,--indent) << "</xs:attribute>"; PrintASNNewLine(out,--indent) << "</xs:complexType>"; return true; }
// XML schema generator submitted by // Marc Dumontier, Blueprint initiative, [email protected] // modified by Andrei Gourianov, gouriano@ncbi void CReferenceDataType::PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only) const { string tag(XmlTagName()); string userType(UserTypeXmlTagName()); if (tag == userType || (GetEnforcedStdXml() && contents_only)) { if (IsRefToParent()) { const CDataType* par = GetParentType(); while ( par->GetParentType() ) { par = par->GetParentType(); } PrintASNNewLine(out,indent) << "<xs:element name=\"" << userType << "\"" << " type=\"" << par->GetMemberName() << userType << "_Type\""; if (GetDataMember()) { if (GetDataMember()->Optional()) { out << " minOccurs=\"0\""; } if (GetDataMember()->GetDefault()) { out << " default=\"" << GetDataMember()->GetDefault()->GetXmlString() << "\""; } } out << "/>"; return; } PrintASNNewLine(out,indent) << "<xs:element ref=\"" << userType << "\""; if (GetDataMember()) { if (GetDataMember()->Optional()) { out << " minOccurs=\"0\""; } if (GetDataMember()->GetDefault()) { out << " default=\"" << GetDataMember()->GetDefault()->GetXmlString() << "\""; } } out << "/>"; } else { if (!contents_only) { PrintASNNewLine(out,indent++) << "<xs:element name=\"" << tag << "\""; if (GetDataMember() && GetDataMember()->Optional()) { out << " minOccurs=\"0\""; } out << ">"; PrintASNNewLine(out,indent++) << "<xs:complexType>"; PrintASNNewLine(out,indent++) << "<xs:sequence>"; } PrintASNNewLine(out,indent) << "<xs:element ref=\"" << userType << "\"/>"; if (!contents_only) { PrintASNNewLine(out,--indent) << "</xs:sequence>"; PrintASNNewLine(out,--indent) << "</xs:complexType>"; PrintASNNewLine(out,--indent) << "</xs:element>"; } } }
CTypeInfo* CReferenceDataType::CreateTypeInfo(void) { CClassTypeInfo* info = CClassInfoHelper<AnyType>::CreateClassInfo(m_UserTypeName.c_str()); info->SetImplicit(); CMemberInfo* memInfo = info->AddMember("", 0, ResolveOrThrow()->GetTypeInfo()); const CDataMember *mem = GetDataMember(); if (!mem && GetParentType()) { mem = GetParentType()->GetDataMember(); } if (mem) { if (mem->Optional()) { memInfo->SetOptional(); } if (mem->NoPrefix()) { memInfo->SetNoPrefix(); } if (IsNillable()) { memInfo->SetNillable(); } } if ( GetParentType() == 0 ) { // global info->SetModuleName(GetModule()->GetName()); } return info; }
void CAnyContentDataType::PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only) const { const CDataMember* mem = GetDataMember(); if (mem) { PrintASNNewLine(out,indent) << "<xs:any processContents=\"lax\""; const string& ns = GetNamespaceName(); if (!ns.empty()) { out << " namespace=\"" << ns << "\""; } if (mem->Optional()) { out << " minOccurs=\"0\""; } out << "/>"; } else { if (!contents_only) { PrintASNNewLine(out,indent++) << "<xs:element name=\"" << XmlTagName() << "\">"; } PrintASNNewLine(out,indent++) << "<xs:complexType>"; PrintASNNewLine(out,indent++) << "<xs:sequence>"; PrintASNNewLine(out,indent) << "<xs:any processContents=\"lax\"/>"; PrintASNNewLine(out,--indent) << "</xs:sequence>"; PrintASNNewLine(out,--indent) << "</xs:complexType>"; if (!contents_only) { PrintASNNewLine(out,--indent) << "</xs:element>"; } } }
void CBoolDataType::PrintDTDExtra(CNcbiOstream& out) const { const char *attr; const CBoolDataValue *val = GetDataMember() ? dynamic_cast<const CBoolDataValue*>(GetDataMember()->GetDefault()) : 0; if(val) { attr = val->GetValue() ? "\"true\"" : "\"false\""; } else { attr = "#REQUIRED"; } out << "\n<!ATTLIST "<<XmlTagName()<<" value ( true | false ) " << attr << " >\n"; }
void CStaticDataType::PrintDTDElement(CNcbiOstream& out, bool contents_only) const { string tag(XmlTagName()); string content(GetXMLContents()); if (GetParentType() && GetParentType()->GetDataMember() && GetParentType()->GetDataMember()->Attlist()) { const CDataMember* mem = GetDataMember(); out << "\n " << tag; const CBoolDataType* bt = dynamic_cast<const CBoolDataType*>(this); if (bt) { out << " ( true | false ) "; } else { out << " CDATA "; } if (mem->GetDefault()) { out << "\"" << mem->GetDefault()->GetXmlString() << "\""; } else { if (mem->Optional()) { out << "#IMPLIED"; } else { out << "#REQUIRED"; } } } else { string open("("), close(")"); if (content == "EMPTY") { open.erase(); close.erase(); } if (!contents_only) { out << "\n<!ELEMENT " << tag << ' ' << open; } out << content; if (!contents_only) { out << close << ">"; } } }
// XML schema generator submitted by // Marc Dumontier, Blueprint initiative, [email protected] // modified by Andrei Gourianov, gouriano@ncbi void CStaticDataType::PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only) const { string tag( XmlTagName()); string xsdk("element"), use, form; const CDataMember* mem = GetDataMember(); bool optional = mem ? mem->Optional() : false; if (GetParentType() && GetParentType()->GetDataMember()) { if (GetParentType()->GetDataMember()->Attlist()) { xsdk = "attribute"; if (optional) { use = "optional"; if (mem->GetDefault()) { use += "\" default=\"" + mem->GetDefault()->GetXmlString(); } } else { use = "required"; } if (IsNsQualified() == eNSQualified) { form = " form=\"qualified\""; } } } PrintASNNewLine(out, indent) << "<xs:" << xsdk << " name=\"" << tag << "\""; string type = GetSchemaTypeString(); if (!type.empty()) { out << " type=\"" << type << "\""; } if (!use.empty()) { out << " use=\"" << use << "\""; } else { if (GetXmlSourceSpec()) { if (optional) { out << " minOccurs=\"0\""; } if (mem && mem->GetDefault()) { out << " default=\"" << mem->GetDefault()->GetXmlString() << "\""; } } else { const CBoolDataType* bt = dynamic_cast<const CBoolDataType*>(this); if (mem && optional) { if (bt) { out << " minOccurs=\"0\""; } else { if (mem->GetDefault()) { out << " default=\"" << mem->GetDefault()->GetXmlString() << "\""; } else { out << " minOccurs=\"0\""; } } } } } if (!form.empty()) { out << form; } if (type.empty() && PrintXMLSchemaContents(out,indent+1)) { PrintASNNewLine(out, indent) << "</xs:" << xsdk << ">"; } else { out << "/>"; } }