xsl-list
[Top] [All Lists]

Re: [xsl] DTD entities in XSLT

2020-08-24 06:26:56

Thanks. Will this work in Saxon-HE? I'm looking for a solution that
could be used in open-source code.

Yes, of course. There's nothing in the query "." that needs EE capabilities!

You could also, of course, use a Java identity transformer 
(TransformerFactory.newProcessor()), which might be faster as it's fully 
streamed.

Michael Kay
Saxonica

On Mon, Aug 24, 2020 at 1:15 PM Michael Kay mike(_at_)saxonica(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Well, you could run the XQuery "." on Java, which would give you a document 
in which all the entity references are expanded.

java net.sf.saxon.Query -qs:"." -s:in.xml -o:out.xml

Michael Kay
Saxonica



On 24 Aug 2020, at 12:07, Martynas Jusevičius 
martynas(_at_)atomgraph(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi,

trying to set up Saxon-JS 2 I hit a snag immediately, but I think the
question is general enough for this list.

The problem is DTD entities. Saxon-JS 2 documentation says:
"The XML parser used on Node.js skips any internal or external DTD.
Any named entity references appearing in a document will therefore be
flagged as errors, causing parsing (and hence transformation) to
fail."

Sure enough, when trying to generate the SEF file, I get an error:

Failed to compile stylesheet: Reference to unknown entity &typeahead;
at line 32 column 28
Error FODC0002
  Failed to compile stylesheet
Error FODC0002
  Reference to unknown entity &typeahead; at line 32 column 28

And all our stylesheets use a bunch of internal DTD entities (example below).
Would it be possible to somehow pre-process them and inline the
entities, so that I can keep them in the source file and still make
Saxon-JS happy?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY typeahead  "http://graphity.org/typeahead#";>
  <!ENTITY lapp       
"https://w3id.org/atomgraph/linkeddatahub/apps/domain#";>
  <!ENTITY apl        "https://w3id.org/atomgraph/linkeddatahub/domain#";>
  <!ENTITY ac         "https://w3id.org/atomgraph/client#";>
  <!ENTITY a          "https://w3id.org/atomgraph/core#";>
  <!ENTITY rdf        "http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
  <!ENTITY rdfs       "http://www.w3.org/2000/01/rdf-schema#";>
  <!ENTITY xsd        "http://www.w3.org/2001/XMLSchema#";>
  <!ENTITY owl        "http://www.w3.org/2002/07/owl#";>
  <!ENTITY skos       "http://www.w3.org/2004/02/skos/core#";>
  <!ENTITY srx        "http://www.w3.org/2005/sparql-results#";>
  <!ENTITY http       "http://www.w3.org/2011/http#";>
  <!ENTITY ldt        "https://www.w3.org/ns/ldt#";>
  <!ENTITY c          "https://www.w3.org/ns/ldt/core/domain#";>
  <!ENTITY dh         "https://www.w3.org/ns/ldt/document-hierarchy/domain#";>
  <!ENTITY sd         "http://www.w3.org/ns/sparql-service-description#";>
  <!ENTITY sp         "http://spinrdf.org/sp#";>
  <!ENTITY spin       "http://spinrdf.org/spin#";>
  <!ENTITY dct        "http://purl.org/dc/terms/";>
  <!ENTITY foaf       "http://xmlns.com/foaf/0.1/";>
  <!ENTITY sioc       "http://rdfs.org/sioc/ns#";>
]>
<xsl:stylesheet
xmlns:xhtml="http://www.w3.org/1999/xhtml";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT";
xmlns:prop="http://saxonica.com/ns/html-property";
xmlns:style="http://saxonica.com/ns/html-style-property";
xmlns:js="http://saxonica.com/ns/globalJS";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:typeahead="&typeahead;"
xmlns:a="&a;"
xmlns:ac="&ac;"
xmlns:lapp="&lapp;"
xmlns:apl="&apl;"
xmlns:rdf="&rdf;"
xmlns:rdfs="&rdfs;"
xmlns:owl="&owl;"
xmlns:ldt="&ldt;"
xmlns:core="&c;"
xmlns:dh="&dh;"
xmlns:srx="&srx;"
xmlns:sd="&sd;"
xmlns:sp="&sp;"
xmlns:spin="&spin;"
xmlns:dct="&dct;"
xmlns:foaf="&foaf;"
xmlns:sioc="&sioc;"
xmlns:skos="&skos;"
xmlns:bs2="http://graphity.org/xsl/bootstrap/2.3.2";
exclude-result-prefixes="xs prop"
extension-element-prefixes="ixsl"
version="2.0"




Martynas


XSL-List info and archive
EasyUnsubscribe (by email)

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>