I am converting XML to (sort) HTML with XSL stylesheets (using Apache Xalan). In XML, there may be objects such as —that should be left as is. At the beginning of the XML file, I have a doctype that references these objects. What should I do to ensure that the object remains unchanged?
—
<!DOCTYPE article [ <!ENTITY mdash "—"><!-- em dash --> ]>
gives me SAXParseException: Recursive entity expansion, 'mdash'when meeting &mdashin XML text.
SAXParseException: Recursive entity expansion, 'mdash'
&mdash
Method for determining and using an object :
<!DOCTYPE xsl:stylesheet [<!ENTITY mdash "—">]> <t>Hello — World!</t>
When processed using the simplest XSLT stylesheet :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> </xsl:stylesheet>
The correct output (containing mdash) is produced:
Hello β World!
Attention!
XSLT 2.0 <xsl:character-map>, , . :
<xsl:character-map>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration="yes" use-character-maps="mdash"/> <xsl:character-map name="mdash"> <xsl:output-character character="—" string="&mdash;" /> </xsl:character-map> </xsl:stylesheet>
XML ( ), :
Hello — World!
, ?
. Entity XML , XSLT, , XPath. DOCTYPE .
, <xsl:output encoding="us-ascii">, ASCII, em-dash —.
<xsl:output encoding="us-ascii">
—
XSLT 2.0 " ", , β — , a β, β , , —. XSLT 2.0, hack , β —. , , , β .
β
" ββ ", , . HTML, Unicode, , , .
Source: https://habr.com/ru/post/1743170/More articles:JQuery tooltips on dynamically generated page - javascript.NET Memory Profiler Wanted - .netMulti-column latex problems - latexHow can I verify that I have uploaded the entire file in Perl? - perlPython DSA module - pythonPHP Value Object automatically creates - objectSpring and hibernate configuration (using maven): java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration - javaDefault button after uninstall and setVisible - javaGet value from thick box control - javascriptΠ‘ΠΏΡΠ°Π²ΠΊΠ° JQuery Ajax - jqueryAll Articles