In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of spaces in xml, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
It is only suitable for scholars who have some understanding of xml file structure, not for beginners. Please read from top to bottom.
Spaces are not important to html files; however, for xml, the default position is to retain space nodes (for an explanation of space nodes, see below).
According to the xml specification, a space is an arbitrary combination of four characters:
White space character (space) with a corresponding character value of # x20
Return character (Carriage Return), corresponding character value is # xD
New line character (Newline), corresponding character value is # xA
A tabbed character (Tab) with a corresponding character value of # x9.
Spaces in xml files also form nodes, that is, space nodes. The space node belongs to the text node type.
For xml and xslt, space nodes involve two issues:
one. Decide which spaces are important in the xml input file, and the xslt processor should see these space nodes. And the key determined is the xml:space attribute.
two. Decide which spaces are important in the xsl template file, and the xslt processor should copy it into the result tree, and the determined key is xsl:strip-space
And xsl:PReserve-space.
"important and unimportant space nodes"
If the contents of a component can only be placed in a component, the space nodes in that component are Insignificant.
If the content of a component is of type # PCDATA, the space nodes within it should be considered important (Signficant).
As for the situation in which the component content is mixed with text content and component, it is impossible to judge, but should depend on the meaning of the component and its content.
Before the xslt processor touches the xml input file, it will be analyzed by the xml parser.
(1) the xml:space attribute can change the mode in which subsequent xml applications handle white space nodes. For example, the xslt processor will be affected by the xml:space attribute.
(2) the ending symbol at the end of any column of markers or content in the xml file will all be replaced with a single new line character (# xA).
(3) the xml parser should also normalize the attribute value before handing it to the xml application. This is because different operating systems have different combinations of characters at the end of each line of text column. For example, windows systems will consist of return characters and new line characters, while Unix systems will only have new line character groups.
It ends with a symbol. After reading the xml file, the xml analyzer first changes all the ending symbols into a single new line character, which not only unifies the differences in the design of different ending symbols between different systems, but also simplifies the operation difficulty of subsequent xml applications. Such a process is called "Normalization".
A, the ending symbol of each text column is normalized to a single new line character (# xA).
B, any space character (# x20, # xD, # xA, # x9) should be replaced with a space character (# x20).
C, if the attribute value contains a reference code, it should be replaced with the reference character, such as
It is replaced with a new line character (# xA).
D, if the attribute value contains an entity reference, it should be replaced with its replacement text.
E, in addition, any character should be placed directly in the normalized attribute value.
Finally, if the attribute type is not CDATA, the xml parser should further delete the sequence of space characters before and after the attribute value, and replace it with a single space character if there is a space sequence in the middle of the attribute value.
After building the structure tree of the xml input file and the xsl template file, the xslt processor will merge the adjacent text nodes in the component into a single text node, and then extract some text nodes. However, a text node is preserved if it meets one of the following conditions:
(1) the parent component of the text node is a member of the space reserved component name set (Set Of Whitespace-preserving Element Names).
(2) there is at least one non-space character in the text node.
(3) there is a xml:space attribute in one of the ancestor components of the literal node, whose value is preserve, and there is no other xml:space attribute whose value is default in the nearest ancestor component. In addition, the text node teasing will be removed.
For xsl templates, the so-called space reserved component name set has only one xsl:text component available. The space node of the xsl template file is deleted, but if the space node appears in the xsl:text component, it will be retained.
Thank you for reading this article carefully. I hope the article "sample Analysis of spaces in xml" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un