当前位置:网站首页>Specify the character set to output
Specify the character set to output
2022-07-04 19:32:00 【User 7741497】
Specify the character set of the output
To specify the character set to be used in the output document , You can set Writer Example of Charset attribute . Options include “UTF-8”、“UTF-16” as well as InterSystems IRIS Other character sets supported .
Writing the Prolog
XML Preface to the document ( The part before the root element ) Can contain document type declarations 、 Processing instructions and comments .
influence Prolog Properties of
stay writer In the example , The following properties affect prolog:
Charset
Control two things :XML The character set declaration in the declaration and ( Corresponding ) The character set encoding used in the output .
NoXmlDeclaration
Controls whether the output contains XML Statement . in the majority of cases , The default value is 0, This means that a declaration has been written . If no character set is specified , And the output is directed to a string or character stream , The default is 1, And don't write any declarations .
Generate document type declaration
Before the root element , Can contain document type declarations , This declaration declares the schema used in the document . To generate a document type declaration , Need to use WriteDocType() Method , This method has one required parameter and three optional parameters . For the purposes of this document , The document type declaration includes the following possible parts :
<!DOCTYPE doc_type_name external_subset [internal_subset]>As shown here , The document type has a name , according to XML The rules , The name must be the name of the root element . Declarations can contain external subsets 、 Internal subset or both .
external_subset Some point to other places DTD file . The structure of this section is any of the following :
PUBLIC public_literal_identifier
PUBLIC public_literal_identifier system_literal_identifier
SYSTEM system_literal_identifier here public_literal_identifier and system_literal_identifier Is included DTD uri String . Be careful ,DTD It can have both public identifier and system identifier . The following is an example of a document type declaration , It contains an external subset that uses both public and system identifiers :
<!DOCTYPE hatches <!ENTITY open-hatch
PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
"http://www.textuality.com/boilerplate/OpenHatch.xml">>internal_subset Part is a set of entity declarations . The following is an example of a document type declaration , It contains only a set of internal declarations :
<!DOCTYPE teams [ <!ENTITY baseball team (name,city,player*)>
!ENTITY name (#PCDATA)>
!ENTITY city (#PCDATA)>
!ENTITY player (#PCDATA)>
] >WriteDocType() Method has four parameters :
- The first parameter specifies the name of the document type , Used in this XML Use... In the document . This is necessary , And it must be effective XML identifier . This name must also be used as the name of the root level element in this document .
- The optional second and third parameters specify the external part of the declaration , As shown below :
WriteDocType Parameters
The second parameter | The third parameter | Other parts |
|---|---|---|
“publicURI” | null | PUBLIC “publicURI” |
“publicURI” | “systemURI” | PUBLIC “publicURI” “systemURI” |
null | “systemURI” | SYSTEM “systemURI” |
- The optional fourth parameter specifies the inner part of the declaration . If this parameter is not empty , Then enclose it in square brackets
[]in , And appropriately placed at the end of the declaration . No other characters were added .
Write processing instructions
To write processing instructions XML, Please use WriteProcessingInstruction() Method , This method has two parameters :
- A processing instruction ( Also known as goal ) The name of .
- The instruction itself is a string .
This method writes the following to XML:
<?name instructions?>for example , To write the following processing instructions :
<?xml-stylesheet type="text/css" href="mystyles.css"?> So , Can be called as follows WriteProcessingInstruction() Method :
set instructions="type=""text/css"" href=""mystyles.css"""
set status=writer.WriteProcessingInstruction("xml-stylesheet", instructions)Specify the default namespace
In the writer instance , You can specify the default namespace , This namespace applies only to non Namespace Parameter setting class . There are several options :
- You can specify the default namespace in the output method . Four main output methods (
RootObject()、RootElement()、Object()orElement()) Both accept namespaces as parameters . Only if it is not set in the class definitionNamespaceWhen parameters are , Will assign relevant elements toNamespace. - You can specify the overall default namespace for the writer instance . So , Please write an instance of
DefaultNamespaceProperty specifies the value .
Class Writers.BasicDemoPerson Extends (%RegisteredObject, %XML.Adaptor)
{
Parameter XMLNAME = "Person";
Property Name As %Name;
Property DOB As %Date;
}By default , If we only export such objects , We'll see the output as follows :
<?xml version="1.0" encoding="UTF-8"?>
<Person>
<Name>Persephone MacMillan</Name>
<DOB>1976-02-20</DOB>
</Person> contrary , If we are in the writer instance take DefaultNamespace Set to "http://www.person.org", Then export an object , You will receive the output shown below :
<?xml version="1.0" encoding="UTF-8"?>
<Person xmlns="www.person.org">
<Name>Persephone MacMillan</Name>
<DOB>1976-02-20</DOB>
</Person> In this case , <Person> The element uses the default namespace , Otherwise, it will not be assigned to the namespace .
边栏推荐
- To sort out messy header files, I use include what you use
- 请教一下 flinksql中 除了数据统计结果是状态被保存 数据本身也是状态吗
- Shell programming core technology "I"
- 大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
- Lm10 cosine wave homeopathic grid strategy
- Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
- In flinksql, in addition to data statistics, is the saved data itself a state
- 在线文本行固定长度填充工具
- Bi skills - permission axis
- 2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
猜你喜欢

用实际例子详细探究OpenCV的轮廓绘制函数drawContours()

Opencv functions and methods related to binary threshold processing are summarized for comparison and use

Use canal and rocketmq to listen to MySQL binlog logs
牛客小白月赛7 谁是神箭手

大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行

更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?

Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?

每日一题(2022-07-02)——最低加油次数

使用canal配合rocketmq监听mysql的binlog日志

联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
随机推荐
HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
IBM WebSphere MQ retrieving messages
node_exporter部署
Shell programming core technology "three"
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
2021 Hefei informatics competition primary school group
Technology sharing | interface testing value and system
Wechat reading notes of "work, consumerism and the new poor"
Leetcode fizzbuzz C # answer
建立自己的网站(15)
Go微服务(二)——Protobuf详细入门
数组中的第K个最大元素
redis分布式锁的8大坑总结梳理
Shell 编程核心技术《四》
反射(一)
Hough Transform 霍夫变换原理
《看完就懂系列》字符串截取方法substr() 、 slice() 和 substring()之间的区别和用法
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
牛客小白月赛7 谁是神箭手
From automation to digital twins, what can Tupo do?