saxon

Why is the 'quot' entity not being escaped?


When I run

(let [processor  (Processor.)
      builder    (.newDocumentBuilder processor)
      xdm-node   (.build builder
                   (StreamSource.
                     (StringReader.
                       "<!DOCTYPE html><html><body>&quot;a</body></html>")))
      serializer (doto (.newSerializer processor)
                   (.setOutputProperty Serializer$Property/METHOD "html"))]
  (println (.getSaxonProductVersion processor) (.getSaxonEdition processor))
  (.serializeNodeToString serializer xdm-node))

I get

12.3 HE
=> "<!DOCTYPE HTML>\n<html>\n   <body>\"a</body>\n</html>"

while I would expect

12.3 HE
=> "<!DOCTYPE HTML>\n<html>\n   <body>&quot;a</body>\n</html>"

What am I missing?


Solution

  • The serializer will escape anything that needs to be escaped. Quotes and apostrophes only need to be escaped in attribute values.