Beispiel #1
0
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;
}
Beispiel #2
0
bool CComments::PrintSchemaComments(CNcbiOstream& out, int indent, int /*flags*/) const
{
    if ( Empty() ) {
        return false;
    }
    
    out << '>'; // close 'element' tag
#if 0
    PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>";
    ITERATE ( TComments, i, m_Comments ) {
        out << '\n' << *i;
    }
    PrintASNNewLine(out, indent) << "</xs:documentation></xs:annotation>";
#else
    if ( OneLine() ) {
        PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>";
        out << NStr::TruncateSpaces(m_Comments.front());
        out << "</xs:documentation></xs:annotation>";
    }
    else {
        PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>";
        ITERATE ( TComments, i, m_Comments ) {
            out << '\n' << *i;
        }
        PrintASNNewLine(out, indent) << "</xs:documentation></xs:annotation>";
    }
#endif
    return true;
}
Beispiel #3
0
bool CBitStringDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const
{
    out << ">";
    PrintASNNewLine(out,indent++) << "<xs:simpleType>";
    PrintASNNewLine(out,indent++) << "<xs:restriction base=\"xs:string\">";
    PrintASNNewLine(out,indent)   << "<xs:pattern value=\"([0-1])*\"/>";
    PrintASNNewLine(out,--indent) << "</xs:restriction>";
    PrintASNNewLine(out,--indent) << "</xs:simpleType>";
    return true;
}
Beispiel #4
0
// 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>";
        }
    }
}
Beispiel #5
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>";
        }
    }
}
Beispiel #6
0
void CDataMemberContainerType::PrintASN(CNcbiOstream& out, int indent) const
{
    PrintASNTag(out);
    out << GetASNKeyword() << " {";
    ++indent;
    ITERATE ( TMembers, i, m_Members ) {
        PrintASNNewLine(out, indent);
        const CDataMember& member = **i;
        TMembers::const_iterator next = i;
        bool last = ++next == m_Members.end();
        member.PrintASN(out, indent, last);
    }
Beispiel #7
0
CNcbiOstream& CComments::PrintASN(CNcbiOstream& out,
                                  int indent, int flags) const
{
    if ( Empty() ) // no comments
        return out;

    bool newLine = (flags & eDoNotWriteBlankLine) == 0;
    // prepend comments by empty line to separate from previous comments

    ITERATE ( TComments, i, m_Comments ) {
        if ( newLine )
            PrintASNNewLine(out, indent);
        out << "--" << NStr::Replace(*i, "--", "");
        newLine = true;
    }

    if ( (flags & eNoEOL) == 0 )
        PrintASNNewLine(out, indent);

    return out;
}
Beispiel #8
0
void CEnumDataType::PrintASN(CNcbiOstream& out, int indent) const
{
    out << GetASNKeyword() << " {";
    ++indent;
    ITERATE ( TValues, i, m_Values ) {
        PrintASNNewLine(out, indent);
        TValues::const_iterator next = i;
        bool last = ++next == m_Values.end();

        bool oneLineComment = i->GetComments().OneLine();
        if ( !oneLineComment )
            i->GetComments().PrintASN(out, indent);
        out << CDataTypeModule::ToAsnId(i->GetName()) << " (" << i->GetValue() << ")";
        if ( !last )
            out << ',';
        if ( oneLineComment ) {
            out << ' ';
            i->GetComments().PrintASN(out, indent, CComments::eOneLine);
        }
    }
Beispiel #9
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 << "/>";
    }
}
Beispiel #10
0
bool CNullDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const
{
    out << ">";
    PrintASNNewLine(out, indent) << "<xs:complexType/>";
    return true;
}