当前位置:网站首页>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 definitionNamespace
When parameters are , Will assign relevant elements toNamespace
. - You can specify the overall default namespace for the writer instance . So , Please write an instance of
DefaultNamespace
Property 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 .
边栏推荐
- The kth largest element in the array
- 牛客小白月赛7 I 新建 Microsoft Office Word 文档
- Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
- 指定输出的字符集
- Detailed explanation of issues related to SSL certificate renewal
- 2021 Hefei informatics competition primary school group
- How test engineers "attack the city" (Part I)
- Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
- 与二值化阈值处理相关的OpenCV函数、方法汇总,便于对比和拿来使用
- node_exporter部署
猜你喜欢
Pytorch学习(四)
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
Pointnet/Pointnet++点云数据集处理并训练
OpenCV的二值化处理函数threshold()详解
Hough Transform 霍夫变换原理
Lm10 cosine wave homeopathic grid strategy
LeetCode第300场周赛(20220703)
SSRS筛选器的IN运算(即包含于)用法
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Nebula importer data import practice
随机推荐
Bi skills - permission axis
使用canal配合rocketmq监听mysql的binlog日志
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Technology sharing | interface testing value and system
HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
Using FTP
In flinksql, in addition to data statistics, is the saved data itself a state
Master the use of auto analyze in data warehouse
Nebula importer data import practice
How test engineers "attack the city" (Part I)
Leetcode ransom letter C # answer
1008 Elevator(20 分)(PAT甲级)
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
LM10丨余弦波动顺势网格策略
《工作、消费主义和新穷人》的微信读书笔记
876. Intermediate node of linked list
Opencv functions and methods related to binary threshold processing are summarized for comparison and use
Summary and sorting of 8 pits of redis distributed lock
Shell 编程核心技术《一》
2022养生展,健康展,北京大健康展,健康产业展11月举办