[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: The entity was referenced, but not declared.

Subject: Re: 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
Re:  The entity was referenced
>  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, "&amp;[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 "&#x2013;" >
>     <!ENTITY mdash "&#x2014;" >
> ]>
> <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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.