search
HomeBackend DevelopmentXML/RSS TutorialDetailed introduction to the complete explanation of spaces in xml

Tips: I extracted the core part of the explanation of spaces in "XSLT From Beginner to Master" to use it as a starting point. I hope everyone will actively participate in the discussion. Talk about your understanding of spaces.

Only suitable for scholars who have a certain understanding of xml file structure, not suitable for beginners. Please read from top to bottom.


For html files, spaces are not important; however, for xml, the default position is to retain space nodes (see below for an explanation of space nodes).


According to the XML specification, the so-called space is any combination sequence of four characters:
-------------------- --
space character (space), the corresponding character value is #x20
return character (Carriage Return), the corresponding character value is #xD
newline character (Newline), the corresponding character value is #xA
Tab character (Tab), the corresponding character value is #x9.

The spaces in the xml file will also form nodes, which are space nodes. Space nodes belong to the text node type.

For XML and ##1. To determine which spaces in the xml input file are important, the xslt processor needs to see these space nodes. The key to the decision is the xml:space attribute.
2. To determine which spaces are important in the xsl template file, the xslt processor should copy it to the result tree, and the key to the decision is the two commands xsl:strip-space
and xsl:PReserve-space.

"Important and unimportant space nodes"

-----------------------
If someone The content of a component can only contain components, so the space nodes in the component are insignificant;
If the content of a component is of type #PCDATA, the space nodes within it should be considered important. (Significant).
As for the situation where the component content mixes text content and components, it is impossible to judge. It should depend on the semantic meaning of the component and its content.

Before the xslt processor comes into contact with the xml input file, it will be analyzed by the xml parser

-------------------- ---
(1) The xml:space attribute can change the mode of processing space nodes by subsequent XML applications. For example, the xslt processor will be affected by the xml:space attribute.
(2) The ending symbols at the end of any column mark or content in the xml file will be replaced by a single new line character (#xA).
(3) Before the attribute value is handed over to the XML application, the XML parser should also perform standardized operations on the attribute value. This is because different operating systems have different combinations of the ending characters of each line of text. For example, the Windows system will end with the return character and the new line character, while the Unix system will only end with the new line character group
symbol. After the XML parser reads the XML file, it first replaces all the ending symbols with a single new line character. This 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 end character of each text column must be normalized to a single newline character (#xA).
b, any space character (#x20, #xD, #xA, #x9) should be replaced by a space character (#x20).
c. If the attribute value contains a word parameter code, it should be replaced with this reference character. For example, will be 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, any characters other than this should be placed directly into the normalized attribute value.
f. 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 if there is a sequence of spaces in the middle of the attribute value, it should also be replaced with a single space character.
 
 
After the xslt processor builds the structure tree of the xml input file and xsl template file, it will merge the adjacent text nodes in the component into a single text node, and then merge some Remove text nodes. However, if the text node meets one of the following conditions, it will be retained:
------------------------
(1) The parent component of the text node is a member of the Set Of Whitespace-preserving Element Names.
(2) There is at least one non-space character in the text node.
(3) There is an xml:space attribute in an ancestor component of the text node, and its value is preserve, and there is no other xml:space attribute value in the recent ancestor component that is default. Other text nodes will be removed.

For xsl templates, only one xsl:text component is available in the so-called space-preserving component name set. The space nodes in the xsl template file will be deleted, but if the space nodes appear in the xsl:text component, they will be retained.


The above is a detailed introduction to the complete explanation of spaces in xml. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
RSS in XML: Unveiling the Core of Content SyndicationRSS in XML: Unveiling the Core of Content SyndicationApr 22, 2025 am 12:08 AM

The implementation of RSS in XML is to organize content through a structured XML format. 1) RSS uses XML as the data exchange format, including elements such as channel information and project list. 2) When generating RSS files, content must be organized according to specifications and published to the server for subscription. 3) RSS files can be subscribed through a reader or plug-in to automatically update the content.

Beyond the Basics: Advanced RSS Document FeaturesBeyond the Basics: Advanced RSS Document FeaturesApr 21, 2025 am 12:03 AM

Advanced features of RSS include content namespaces, extension modules, and conditional subscriptions. 1) Content namespace extends RSS functionality, 2) Extended modules such as DublinCore or iTunes to add metadata, 3) Conditional subscription filters entries based on specific conditions. These functions are implemented by adding XML elements and attributes to improve information acquisition efficiency.

The XML Backbone: How RSS Feeds are StructuredThe XML Backbone: How RSS Feeds are StructuredApr 20, 2025 am 12:02 AM

RSSfeedsuseXMLtostructurecontentupdates.1)XMLprovidesahierarchicalstructurefordata.2)Theelementdefinesthefeed'sidentityandcontainselements.3)elementsrepresentindividualcontentpieces.4)RSSisextensible,allowingcustomelements.5)Bestpracticesincludeusing

RSS & XML: Understanding the Dynamic Duo of Web ContentRSS & XML: Understanding the Dynamic Duo of Web ContentApr 19, 2025 am 12:03 AM

RSS and XML are tools for web content management. RSS is used to publish and subscribe to content, and XML is used to store and transfer data. They work with content publishing, subscriptions, and update push. Examples of usage include RSS publishing blog posts and XML storing book information.

RSS Documents: The Foundation of Web SyndicationRSS Documents: The Foundation of Web SyndicationApr 18, 2025 am 12:04 AM

RSS documents are XML-based structured files used to publish and subscribe to frequently updated content. Its main functions include: 1) automated content updates, 2) content aggregation, and 3) improving browsing efficiency. Through RSSfeed, users can subscribe and get the latest information from different sources in a timely manner.

Decoding RSS: The XML Structure of Content FeedsDecoding RSS: The XML Structure of Content FeedsApr 17, 2025 am 12:09 AM

The XML structure of RSS includes: 1. XML declaration and RSS version, 2. Channel (Channel), 3. Item. These parts form the basis of RSS files, allowing users to obtain and process content information by parsing XML data.

How to Parse and Utilize XML-Based RSS FeedsHow to Parse and Utilize XML-Based RSS FeedsApr 16, 2025 am 12:05 AM

RSSfeedsuseXMLtosyndicatecontent;parsingtheminvolvesloadingXML,navigatingitsstructure,andextractingdata.Applicationsincludebuildingnewsaggregatorsandtrackingpodcastepisodes.

RSS Documents: How They Deliver Your Favorite ContentRSS Documents: How They Deliver Your Favorite ContentApr 15, 2025 am 12:01 AM

RSS documents work by publishing content updates through XML files, and users subscribe and receive notifications through RSS readers. 1. Content publisher creates and updates RSS documents. 2. The RSS reader regularly accesses and parses XML files. 3. Users browse and read updated content. Example of usage: Subscribe to TechCrunch's RSS feed, just copy the link to the RSS reader.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software