예제 #1
0
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>";
        }
    }
}
예제 #2
0
파일: reftype.cpp 프로젝트: swuecho/igblast
void CReferenceDataType::PrintDTDElement(CNcbiOstream& out, bool contents_only) const
{
    string tag(XmlTagName());
    string userType(UserTypeXmlTagName());
    const CUniSequenceDataType* uniType = 
        dynamic_cast<const CUniSequenceDataType*>(GetParentType());

    if (tag == userType || (GetEnforcedStdXml() && uniType)) {
        const CDataType* realType = ResolveOrNull();
        if (realType) {
            realType->PrintDTDElement(out, contents_only);
        }
        return;
    }
    out <<
        "\n<!ELEMENT "<<XmlTagName()<<" ("<<UserTypeXmlTagName()<<")>";
}
예제 #3
0
파일: reftype.cpp 프로젝트: swuecho/igblast
// 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>";
        }
    }
}
예제 #4
0
void CAnyContentDataType::PrintDTDElement(CNcbiOstream& out, bool contents_only) const
{
    if (!contents_only) {
        out << "\n<!ELEMENT " << XmlTagName() << " ";
    }
    out << GetXMLContents();
    if (!contents_only) {
        out << ">";
    }
}
예제 #5
0
파일: reftype.cpp 프로젝트: swuecho/igblast
void CReferenceDataType::PrintDTDExtra(CNcbiOstream& out) const
{
    string tag(XmlTagName());
    string userType(UserTypeXmlTagName());
    const CUniSequenceDataType* uniType = 
        dynamic_cast<const CUniSequenceDataType*>(GetParentType());

    if (tag == userType || (GetEnforcedStdXml() && uniType)) {
        const CDataType* realType = ResolveOrNull();
        if (realType) {
            realType->PrintDTDExtra(out);
        }
    }
}
예제 #6
0
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";
}
예제 #7
0
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 << ">";
        }
    }
}
예제 #8
0
// 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 << "/>";
    }
}