Altova XMLSpy 2023 Enterprise Edition

当从XML Schema生成代码时,生成的代码将提供与Schema同名的文档类。此类包含所有可能的根元素作为成员和以下方法。请注意,在以下方法名称中,“CDoc”表示生成的文档类本身的名称。

 

方法

Name

描述

static CDoc CreateDocument()

创建一个新的空白XML文档。必须使用DestroyDocument()释放。

static void DeclareAllNamespacesFromSchema(ElementType& node)

在作为参数提供的元素(通常是XML根元素)上声明来自XML Schema的所有命名空间。如果您的Schema具有多个命名空间声明,每个都被映射到一个前缀,并且您希望在作为参数提供的元素上声明所有这些命名空间,则调用此方法很有用。

void DestroyDocument()

销毁文档。对文档及其节点的所有引用均无效。当您处理完文档时,必须调用此方法。

static CDoc LoadFromBinary(const std:vector<unsigned char>& xml)

从字节数组加载XML文档。

static CDoc LoadFromFile(const string_type& fileName)

从文件加载XML文档。

static CDoc LoadFromString(const string_type& xml)

从字符串加载XML文档。

std::vector<unsigned char> SaveToBinary(bool prettyPrint)

将XML文档保存到字节数组。设为true时,prettyPrint参数将重新调整XML文档的格式以获得更好的可读性。

std::vector<unsigned char> SaveToBinary(bool prettyPrint, const string_type & encoding)

将XML文档保存到字节数组,可选择“代码美化”格式设置,并使用指定的编码。

std::vector<unsigned char> SaveToBinary(bool prettyPrint, const string_type & encoding, bool bBigEndian, bool bBOM)

将XML文档保存到字节数组,可选择“代码美化”格式设置,并使用指定的编码。可以为Unicode编码指定字节顺序和Unicode字节顺序标记。

void SaveToFile(const string_type & fileName, bool prettyPrint)

将XML文档保存到文件,可选择“代码美化”格式设置。

void SaveToFile(const string_type & fileName, bool omitXmlDecl)

将XML文档保存到文件。如果将omitXmlDecl参数设为true,则不会写入XML声明。

void SaveToFile(const string_type & fileName, bool omitXmlDecl, const string_type & encoding)

将XML文档保存到文件,并使用指定的编码。如果将omitXmlDecl参数设为true,则不会写入XML声明。

void SaveToFile(const string_type & fileName, bool prettyPrint, bool omitXmlDecl, const string_type & encoding, bool bBigEndian, bool bBOM)

将XML文档保存到文件,可选择“代码美化”格式设置,并使用指定的编码。可以为Unicode编码指定字节顺序和Unicode字节顺序标记。

void SaveToFile(const string_type & fileName, bool prettyPrint, bool omitXmlDecl, const string_type & encoding, bool bBigEndian, bool bBOM, const string_type & lineend)

将XML文档保存到文件,可选择“代码美化”格式设置,并使用指定的编码和行结尾。可以为Unicode编码指定字节顺序和Unicode字节顺序标记。

 

此方法仅在您为Xerces3 XML library生成代码时可用(请参见代码生成器选项)。

void SaveToFile(const string_type& fileName, bool prettyPrint, bool omitXmlDecl, const string_type & encoding, const string_type & lineend)

将XML文档保存到文件,可选择“代码美化”格式设置,并使用指定的编码和行结尾。

 

此方法仅在您为Xerces3 XML library生成代码时可用(请参见代码生成器选项)。

void SaveToFile(const string_type & fileName, bool prettyPrint, const string_type & encoding)

将XML文档保存到文件,可选择“代码美化”格式设置,并使用指定的编码。

void SaveToFile(const string_type& fileName, bool prettyPrint, const string_type & encoding, bool bBigEndian, bool bBOM)

将XML文档保存到文件,可选择“代码美化”格式设置,并使用指定的编码。可以为Unicode编码指定字节顺序和Unicode字节顺序标记。

void SaveToFile(const string_type& fileName, bool prettyPrint, const string_type & encoding, bool bBigEndian, bool bBOM, const string_type & lineend)

将XML文档保存到文件,并使用指定的编码和行结尾。可以为Unicode编码指定字节顺序和Unicode字节顺序标记。

 

此方法仅在您为Xerces3 XML library生成代码时可用(请参见代码生成器选项)。

void SaveToFile(const string_type& fileName, bool prettyPrint, const string_type & encoding, const string_type & lineend)

将XML文档保存到文件,可选择“代码美化”格式设置,并使用指定的编码和行结尾。

 

此方法仅在您为Xerces3 XML library生成代码时可用(请参见代码生成器选项)。

string_type SaveToString(bool prettyPrint)

将XML文档保存到字符串,可选择“代码美化”格式设置。

string_type SaveToString(bool prettyPrint, bool omitXmlDecl)

将XML文档保存到字符串,可选择“代码美化”格式设置。如果将omitXmlDecl参数设为true,则不会写入XML声明。

void SetDTDLocation(const string_type & dtdLocation)

添加一个带有指定的系统ID的DOCTYPE声明。必须已存在一个根元素。MSXML不支持此方法,因为无法将DOCTYPE声明添加到内存中的文档。

void SetSchemaLocation(const string_type & schemaLocation)

将xsi:schemaLocation或xsi:noNamespaceSchemaLocation特性添加到根元素。必须已存在一个根元素。

© 2017-2023 Altova GmbH