Use OS specific EOL
This commit is contained in:
parent
0c3e138c22
commit
a189fe7c20
|
@ -59,8 +59,9 @@ const wxString &Dtd2Schema::convert ( const wxString &dtdFile )
|
||||||
return mSchema;
|
return mSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSchema << _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
mSchema << _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
|
||||||
_T("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"");
|
<< wxTextFile::GetEOL()
|
||||||
|
<< _T("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"");
|
||||||
|
|
||||||
wxString elements;
|
wxString elements;
|
||||||
const size_t nIndent = 1;
|
const size_t nIndent = 1;
|
||||||
|
@ -83,8 +84,10 @@ const wxString &Dtd2Schema::convert ( const wxString &dtdFile )
|
||||||
targetNS.c_str(), mTargetNameSpace.c_str() );
|
targetNS.c_str(), mTargetNameSpace.c_str() );
|
||||||
}
|
}
|
||||||
if ( !mTargetNameSpace.empty() )
|
if ( !mTargetNameSpace.empty() )
|
||||||
mSchema << _T("\n targetNamespace=\"") << mTargetNameSpace
|
mSchema << wxTextFile::GetEOL()
|
||||||
<< _T("\"\n xmlns=\"") << mTargetNameSpace << _T("\"");
|
<< _T(" targetNamespace=\"") << mTargetNameSpace << _T("\"")
|
||||||
|
<< wxTextFile::GetEOL()
|
||||||
|
<< _T(" xmlns=\"") << mTargetNameSpace << _T("\"");
|
||||||
wxString importNS;
|
wxString importNS;
|
||||||
std::map<wxString, wxString>::iterator itr;
|
std::map<wxString, wxString>::iterator itr;
|
||||||
itr = mNameSpaceMap.find ( _T("xml") );
|
itr = mNameSpaceMap.find ( _T("xml") );
|
||||||
|
@ -92,15 +95,18 @@ const wxString &Dtd2Schema::convert ( const wxString &dtdFile )
|
||||||
itr->second = wxString::FromUTF8 ( (const char *) XML_XML_NAMESPACE );
|
itr->second = wxString::FromUTF8 ( (const char *) XML_XML_NAMESPACE );
|
||||||
for ( itr = mNameSpaceMap.begin(); itr != mNameSpaceMap.end(); ++itr )
|
for ( itr = mNameSpaceMap.begin(); itr != mNameSpaceMap.end(); ++itr )
|
||||||
{
|
{
|
||||||
mSchema << _T("\n xmlns:") << itr->first << _T("=\"")
|
mSchema << wxTextFile::GetEOL()
|
||||||
|
<< _T(" xmlns:") << itr->first << _T("=\"")
|
||||||
<< itr->second << _T("\"");
|
<< itr->second << _T("\"");
|
||||||
importNS << _T(" <xs:import namespace=\"")
|
importNS << _T(" <xs:import namespace=\"")
|
||||||
<< ( itr->second.empty() ? itr->first : itr->second )
|
<< ( itr->second.empty() ? itr->first : itr->second )
|
||||||
<< _T("\"/>\n");
|
<< _T("\"/>")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
}
|
}
|
||||||
mSchema << _T(">\n")
|
mSchema << _T(">")
|
||||||
|
<< wxTextFile::GetEOL()
|
||||||
<< importNS
|
<< importNS
|
||||||
<< _T("\n")
|
<< wxTextFile::GetEOL()
|
||||||
<< elements;
|
<< elements;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -119,7 +125,7 @@ const wxString &Dtd2Schema::convert ( const wxString &dtdFile )
|
||||||
mSchema << convertNotation ( notationEnum.nextElement(), nIndent );
|
mSchema << convertNotation ( notationEnum.nextElement(), nIndent );
|
||||||
}
|
}
|
||||||
|
|
||||||
mSchema << _T("</xs:schema>\n");
|
mSchema << _T("</xs:schema>") << wxTextFile::GetEOL();
|
||||||
|
|
||||||
return mSchema;
|
return mSchema;
|
||||||
}
|
}
|
||||||
|
@ -154,17 +160,20 @@ wxString Dtd2Schema::convertElement
|
||||||
}
|
}
|
||||||
if ( pcdata )
|
if ( pcdata )
|
||||||
{
|
{
|
||||||
schema << _T("\" type=\"xs:string\"/>\n\n");
|
schema << _T("\" type=\"xs:string\"/>")
|
||||||
|
<< wxTextFile::GetEOL()
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// else Complex type
|
// else Complex type
|
||||||
schema << _T("\">\n");
|
schema << _T("\">") << wxTextFile::GetEOL();
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent + 1 );
|
XmlSchemaGenerator::addIndent ( schema, nIndent + 1 );
|
||||||
schema << _T("<xs:complexType>\n")
|
schema << _T("<xs:complexType>")
|
||||||
|
<< wxTextFile::GetEOL()
|
||||||
<< convertContent ( contentSpec, nIndent + 2 );
|
<< convertContent ( contentSpec, nIndent + 2 );
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
|
@ -178,10 +187,12 @@ wxString Dtd2Schema::convertElement
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent + 1);
|
XmlSchemaGenerator::addIndent ( schema, nIndent + 1);
|
||||||
schema << _T("</xs:complexType>\n");
|
schema << _T("</xs:complexType>") << wxTextFile::GetEOL();
|
||||||
|
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("</xs:element>\n\n");
|
schema << _T("</xs:element>")
|
||||||
|
<< wxTextFile::GetEOL()
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
@ -206,9 +217,9 @@ wxString Dtd2Schema::convertContent
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:sequence minOccurs=\"0\">\n");
|
schema << _T("<xs:sequence minOccurs=\"0\">") << wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:sequence>\n");
|
suffix << _T("</xs:sequence>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentSpecNode::ZeroOrMore:
|
case ContentSpecNode::ZeroOrMore:
|
||||||
|
@ -218,9 +229,10 @@ wxString Dtd2Schema::convertContent
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\n");
|
schema << _T("<xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:sequence>\n");
|
suffix << _T("</xs:sequence>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentSpecNode::OneOrMore:
|
case ContentSpecNode::OneOrMore:
|
||||||
|
@ -230,9 +242,10 @@ wxString Dtd2Schema::convertContent
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:sequence maxOccurs=\"unbounded\">\n");
|
schema << _T("<xs:sequence maxOccurs=\"unbounded\">")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:sequence>\n");
|
suffix << _T("</xs:sequence>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentSpecNode::Choice:
|
case ContentSpecNode::Choice:
|
||||||
|
@ -245,10 +258,10 @@ wxString Dtd2Schema::convertContent
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:choice")
|
schema << _T("<xs:choice") << convertOccurrence ( content ) << _T(">")
|
||||||
<< convertOccurrence ( content ) << _T(">\n");
|
<< wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:choice>\n");
|
suffix << _T("</xs:choice>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentSpecNode::Sequence:
|
case ContentSpecNode::Sequence:
|
||||||
|
@ -261,17 +274,18 @@ wxString Dtd2Schema::convertContent
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:sequence")
|
schema << _T("<xs:sequence") << convertOccurrence ( content )
|
||||||
<< convertOccurrence ( content ) << _T(">\n");
|
<< _T(">") << wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:sequence>\n");
|
suffix << _T("</xs:sequence>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentSpecNode::Any:
|
case ContentSpecNode::Any:
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:any") << convertOccurrence ( content ) << _T(">\n");
|
schema << _T("<xs:any") << convertOccurrence ( content ) << _T(">")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:any>\n");
|
suffix << _T("</xs:any>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentSpecNode::All:
|
case ContentSpecNode::All:
|
||||||
|
@ -284,9 +298,10 @@ wxString Dtd2Schema::convertContent
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:all") << convertOccurrence ( content ) << _T(">\n");
|
schema << _T("<xs:all") << convertOccurrence ( content ) << _T(">")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
XmlSchemaGenerator::addIndent ( suffix, nIndent );
|
||||||
suffix << _T("</xs:all>\n");
|
suffix << _T("</xs:all>") << wxTextFile::GetEOL();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -306,11 +321,10 @@ wxString Dtd2Schema::convertContent
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:element ref=\"")
|
schema << _T("<xs:element ref=\"") << name << _T("\"")
|
||||||
<< name
|
|
||||||
<< _T("\"")
|
|
||||||
<< convertOccurrence ( content )
|
<< convertOccurrence ( content )
|
||||||
<< _T("/>\n");
|
<< _T("/>")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
|
|
||||||
size_t index = name.Index ( ':' );
|
size_t index = name.Index ( ':' );
|
||||||
if ( index != wxString::npos )
|
if ( index != wxString::npos )
|
||||||
|
@ -362,7 +376,7 @@ wxString Dtd2Schema::convertAttribute
|
||||||
if ( att.getType() == XMLAttDef::Any_Any )
|
if ( att.getType() == XMLAttDef::Any_Any )
|
||||||
{
|
{
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:anyAttribute/>\n");
|
schema << _T("<xs:anyAttribute/>") << wxTextFile::GetEOL();
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +420,8 @@ wxString Dtd2Schema::convertAttribute
|
||||||
mNameSpaceMap [ ns ]; // Initialize it
|
mNameSpaceMap [ ns ]; // Initialize it
|
||||||
}
|
}
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("<xs:attribute ref=\"") << name << _T("\"/>\n");
|
schema << _T("<xs:attribute ref=\"") << name << _T("\"/>")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,16 +432,18 @@ wxString Dtd2Schema::convertAttribute
|
||||||
//if ( att.getType() == XMLAttDef::Enumeration )
|
//if ( att.getType() == XMLAttDef::Enumeration )
|
||||||
{
|
{
|
||||||
schema << convertAttValue ( att )
|
schema << convertAttValue ( att )
|
||||||
<< _T(">\n")
|
<< _T(">")
|
||||||
|
<< wxTextFile::GetEOL()
|
||||||
<< convertAttType ( att, nIndent + 1 );
|
<< convertAttType ( att, nIndent + 1 );
|
||||||
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
XmlSchemaGenerator::addIndent ( schema, nIndent );
|
||||||
schema << _T("</xs:attribute>\n");
|
schema << _T("</xs:attribute>") << wxTextFile::GetEOL();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
schema << convertAttType ( att, nIndent + 1 )
|
schema << convertAttType ( att, nIndent + 1 )
|
||||||
<< convertAttValue ( att )
|
<< convertAttValue ( att )
|
||||||
<< _T("/>\n");
|
<< _T("/>")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
|
@ -441,9 +458,10 @@ wxString Dtd2Schema::convertAttType ( const XMLAttDef &att, size_t nIndent )
|
||||||
//case XMLAttDef::Enumeration:
|
//case XMLAttDef::Enumeration:
|
||||||
{
|
{
|
||||||
XmlSchemaGenerator::addIndent ( type, nIndent );
|
XmlSchemaGenerator::addIndent ( type, nIndent );
|
||||||
type << _T("<xs:simpleType>\n");
|
type << _T("<xs:simpleType>") << wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( type, nIndent + 1 );
|
XmlSchemaGenerator::addIndent ( type, nIndent + 1 );
|
||||||
type << _T("<xs:restriction base=\"xs:string\">\n");
|
type << _T("<xs:restriction base=\"xs:string\">")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
|
|
||||||
wxStringTokenizer tokens (
|
wxStringTokenizer tokens (
|
||||||
WrapXerces::toString ( att.getEnumeration() ), _T(" ") );
|
WrapXerces::toString ( att.getEnumeration() ), _T(" ") );
|
||||||
|
@ -452,13 +470,14 @@ wxString Dtd2Schema::convertAttType ( const XMLAttDef &att, size_t nIndent )
|
||||||
XmlSchemaGenerator::addIndent ( type, nIndent + 2);
|
XmlSchemaGenerator::addIndent ( type, nIndent + 2);
|
||||||
type << _T("<xs:enumeration value=\"")
|
type << _T("<xs:enumeration value=\"")
|
||||||
<< tokens.GetNextToken()
|
<< tokens.GetNextToken()
|
||||||
<< _T("\"/>\n");
|
<< _T("\"/>")
|
||||||
|
<< wxTextFile::GetEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlSchemaGenerator::addIndent ( type, nIndent + 1 );
|
XmlSchemaGenerator::addIndent ( type, nIndent + 1 );
|
||||||
type << _T("</xs:restriction>\n");
|
type << _T("</xs:restriction>") << wxTextFile::GetEOL();
|
||||||
XmlSchemaGenerator::addIndent ( type, nIndent );
|
XmlSchemaGenerator::addIndent ( type, nIndent );
|
||||||
type << _T("</xs:simpleType>\n");
|
type << _T("</xs:simpleType>") << wxTextFile::GetEOL();
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +599,7 @@ wxString Dtd2Schema::convertNotation
|
||||||
if ( id != NULL )
|
if ( id != NULL )
|
||||||
schema << _T("\" system=\"")
|
schema << _T("\" system=\"")
|
||||||
<< WrapXerces::toString ( id );
|
<< WrapXerces::toString ( id );
|
||||||
schema << _T("\"/>\n\n");
|
schema << _T("\"/>") << wxTextFile::GetEOL() << wxTextFile::GetEOL();
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue