Subject: Re: [xsl] The entity was referenced, but not declared. From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 12 Jun 2023 23:45:06 -0000 |
> Is there any way I can avoid or fix this problem from the XSLT stylesheet without having to modify the input XLIFF files? No, there isn't. The source document isn't well-formed XML, and nothing you do in the stylesheet can change that. You could try reading the input using unparsed-text(). Using Saxon-PE 12.2 you could then do saxon:replace-with($input, "&[A-Za-z]+;", function($str){char(translate($str, "B';", ""))}) Explanation: saxon:replace-with is a function proposed for addition to XPath 4.0 that acts like replace(), but applying a user-defined function to compute the replacement string. The user-defined function in this case invokes the new XPath 4.0 fn:char() function, which recognizes HTML entity names, for example char('ndash') returns the character U+2013. With luck the result will be a well-formed XML document that you can then parse using the parse-xml() function. Michael Kay Saxonica > On 12 Jun 2023, at 23:48, Manuel Souto Pico terminolator@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Dear all, > > I'm trying to convert a collection of XLIFF files into TMX. The files contain some HTML named entities, which makes my stylesheet choke: > > Error on line 8 column 64 of file.xlf: > SXXP0003 Error reported by XML parser: The entity "ndash" was referenced, but not > declared.: The entity "ndash" was referenced, but not declared. > Error > SXXP0003 collection(): failed to parse XML file > file:/home/souto/Sync/PISA25/Assets/PISA2022/03_Preprocessed_MS/input_dir/fil e.xlf: org.xml.sax.SAXParseException; systemId: file:/home/souto/Sync/PISA25/Assets/PISA2022/03_Preprocessed_MS/input_dir/fil e.xlf; lineNumber: 8; columnNumber: 64; The entity "ndash" was referenced, but not declared. > collection(): failed to parse XML file file:/home/souto/Sync/PISA25/Assets/PISA2022/03_Preprocessed_MS/input_dir/fil e.xlf: org.xml.sax.SAXParseException; systemId: file:/home/souto/Sync/PISA25/Assets/PISA2022/03_Preprocessed_MS/input_dir/fil e.xlf; lineNumber: 8; columnNumber: 64; The entity "ndash" was referenced, but not declared. > > Even though the preamble of my stylesheet says: > > <?xml version="1.0" encoding="UTF-8" ?> > <!DOCTYPE xsl:stylesheet [ > <!ENTITY ndash "–" > > <!ENTITY mdash "—" > > ]> > <xsl:stylesheet ... > > My question is: Is there any way I can avoid or fix this problem from the XSLT stylesheet without having to modify the input XLIFF files? > > The example above is with ndash but I believe there must be many HTM named entities in the files. > > Thanks a lot in advance. > Cheers, Manuel > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3500899> (by email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] The entity was referenced, bu, Manuel Souto Pico te | Thread | Re: [xsl] The entity was referenced, Martin Honnen martin |
[xsl] The entity was referenced, bu, Manuel Souto Pico te | Date | Re: [xsl] The entity was referenced, Martin Honnen martin |
Month |