473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

[XSLT] Absolute URI of an unparsed entity and catalog

I would like to know if the base URI considered to resolve an unparsed
entity defined by a relative URI should be the URI before or after its
rewriting due to a possible catalog.

Let's take an example. Here's my XML file:

<?xml version="1.0"?>
<!DOCTYPE para
PUBLIC "-//Norman Walsh//DTD Website Full V2.4.0//EN"
"http://docbook.sourceforge.net/release/website/2.4.0/website-full.dtd"
[
<!ENTITY % entities SYSTEM "http://www.vinc17.org/www.ent">
%entities;
]>
<para><olink targetdocent="local.index.en">test</olink></para>

and my XSLT file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="olink">
<a href="{unparsed-entity-uri(@targetdocent)}">
<xsl:apply-templates/>
</a>
</xsl:template>
</xsl:stylesheet>

http://www.vinc17.org/www.ent is a file in which I define unparsed
entities that are relative to http://www.vinc17.org/. For instance:

<!ENTITY local.index.en SYSTEM "index.en.html" NDATA XML>

As I don't want to connect to http://www.vinc17.org/ to generate the
URI, I use a catalog with the following entry:

<rewriteSystem systemIdStartString="http://www.vinc17.org/www.ent"
rewritePrefix="file:///home/lefevre/wd/www-new/www.ent"/>

(in fact, http://www.vinc17.org/www.ent doesn't even exist in the
reality, however the XSLT processor doesn't have to know that). But
then, xsltproc generates the following file:

<?xml version="1.0"?>
<a href="file:///home/lefevre/wd/www-new/index.en.html">test</a>

instead of:

<?xml version="1.0"?>
<a href="http://www.vinc17.org/index.en.html">test</a>

Is that correct? I would have said that since the XSLT specifications
don't define the notion of catalog, a catalog should be regarded only
as a cacheing system (i.e. transparent for XML generation by XSLT); in
this case, I should have got the version with http://www.vinc17.org/.

Otherwise, I would have been interested in a different version of the
unparsed-entity-uri function that would have yielded a relative URI. If
I define all the URIs and filenames with relative names, then xsltproc
does generate a relative URI, but this URI is relative to the current
directory and not the document defining the entity; therefore this is
not acceptable.

--
Vincent Lefèvre <vi*****@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Jul 20 '05 #1
6 2794
I believe the answer to all such questions should be before. The catalog
should not "show through" to the infoset in any way.

Without any knowledge of how the catalog is implemented, I would guess the
problem is in the entity resolver. It is probably returning the system id of
the actual location it fetched the resource from rather than, as it should,
the "virtual" system id it was handed.

Bob Foster

"Vincent Lefevre" <vi**********@vinc17.org> wrote in message
news:20*****************@vinc17.org...
I would like to know if the base URI considered to resolve an unparsed
entity defined by a relative URI should be the URI before or after its
rewriting due to a possible catalog.

Let's take an example. Here's my XML file:

<?xml version="1.0"?>
<!DOCTYPE para
PUBLIC "-//Norman Walsh//DTD Website Full V2.4.0//EN"
"http://docbook.sourceforge.net/release/website/2.4.0/website-full.dtd"
[
<!ENTITY % entities SYSTEM "http://www.vinc17.org/www.ent">
%entities;
]>
<para><olink targetdocent="local.index.en">test</olink></para>

and my XSLT file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="olink">
<a href="{unparsed-entity-uri(@targetdocent)}">
<xsl:apply-templates/>
</a>
</xsl:template>
</xsl:stylesheet>

http://www.vinc17.org/www.ent is a file in which I define unparsed
entities that are relative to http://www.vinc17.org/. For instance:

<!ENTITY local.index.en SYSTEM "index.en.html" NDATA XML>

As I don't want to connect to http://www.vinc17.org/ to generate the
URI, I use a catalog with the following entry:

<rewriteSystem systemIdStartString="http://www.vinc17.org/www.ent"
rewritePrefix="file:///home/lefevre/wd/www-new/www.ent"/>

(in fact, http://www.vinc17.org/www.ent doesn't even exist in the
reality, however the XSLT processor doesn't have to know that). But
then, xsltproc generates the following file:

<?xml version="1.0"?>
<a href="file:///home/lefevre/wd/www-new/index.en.html">test</a>

instead of:

<?xml version="1.0"?>
<a href="http://www.vinc17.org/index.en.html">test</a>

Is that correct? I would have said that since the XSLT specifications
don't define the notion of catalog, a catalog should be regarded only
as a cacheing system (i.e. transparent for XML generation by XSLT); in
this case, I should have got the version with http://www.vinc17.org/.

Otherwise, I would have been interested in a different version of the
unparsed-entity-uri function that would have yielded a relative URI. If
I define all the URIs and filenames with relative names, then xsltproc
does generate a relative URI, but this URI is relative to the current
directory and not the document defining the entity; therefore this is
not acceptable.

--
Vincent Lefèvre <vi*****@vinc17.org> - Web: <http://www.vinc17.org/> - 100% validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA

Jul 20 '05 #2
3.3 Unparsed Entities

The root node has a mapping that gives the URI for each unparsed entity
declared in the document's DTD. The URI is generated from the system
identifier and public identifier specified in the entity declaration.
The XSLT processor may use the public identifier to generate a URI for
the entity instead of the URI specified in the system identifier. If the
XSLT processor does not use the public identifier to generate the URI,
it must use the system identifier; if the system identifier is a
relative URI, it must be resolved into an absolute URI using the URI of
the resource containing the entity declaration as the base URI [RFC2396].

Vincent Lefevre wrote:
I would like to know if the base URI considered to resolve an unparsed
entity defined by a relative URI should be the URI before or after its
rewriting due to a possible catalog.

Let's take an example. Here's my XML file:

<?xml version="1.0"?>
<!DOCTYPE para
PUBLIC "-//Norman Walsh//DTD Website Full V2.4.0//EN"
"http://docbook.sourceforge.net/release/website/2.4.0/website-full.dtd"
[
<!ENTITY % entities SYSTEM "http://www.vinc17.org/www.ent">
%entities;
]>
<para><olink targetdocent="local.index.en">test</olink></para>

and my XSLT file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="olink">
<a href="{unparsed-entity-uri(@targetdocent)}">
<xsl:apply-templates/>
</a>
</xsl:template>
</xsl:stylesheet>

http://www.vinc17.org/www.ent is a file in which I define unparsed
entities that are relative to http://www.vinc17.org/. For instance:

<!ENTITY local.index.en SYSTEM "index.en.html" NDATA XML>

As I don't want to connect to http://www.vinc17.org/ to generate the
URI, I use a catalog with the following entry:

<rewriteSystem systemIdStartString="http://www.vinc17.org/www.ent"
rewritePrefix="file:///home/lefevre/wd/www-new/www.ent"/>

(in fact, http://www.vinc17.org/www.ent doesn't even exist in the
reality, however the XSLT processor doesn't have to know that). But
then, xsltproc generates the following file:

<?xml version="1.0"?>
<a href="file:///home/lefevre/wd/www-new/index.en.html">test</a>

instead of:

<?xml version="1.0"?>
<a href="http://www.vinc17.org/index.en.html">test</a>

Is that correct? I would have said that since the XSLT specifications
don't define the notion of catalog, a catalog should be regarded only
as a cacheing system (i.e. transparent for XML generation by XSLT); in
this case, I should have got the version with http://www.vinc17.org/.

Otherwise, I would have been interested in a different version of the
unparsed-entity-uri function that would have yielded a relative URI. If
I define all the URIs and filenames with relative names, then xsltproc
does generate a relative URI, but this URI is relative to the current
directory and not the document defining the entity; therefore this is
not acceptable.

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------

Jul 20 '05 #3
In article <bj**********@news-sop.inria.fr>,
Philippe Poulard <Ph**************@sophia.inria.fr> wrote:
3.3 Unparsed Entities The root node has a mapping that gives the URI for each unparsed entity
declared in the document's DTD. The URI is generated from the system
identifier and public identifier specified in the entity declaration.
The XSLT processor may use the public identifier to generate a URI for
the entity instead of the URI specified in the system identifier. If the
XSLT processor does not use the public identifier to generate the URI,
it must use the system identifier; if the system identifier is a
relative URI, it must be resolved into an absolute URI using the URI of
the resource containing the entity declaration as the base URI [RFC2396].


I know how to read the specs. :) But what if catalogs are used?
My point was that this paragraph doesn't mention catalogs; thus, the
XSLT processor should behave as if there were no catalogs (catalogs
are just a transparent way of cacheing resources). In this case, this
would mean that there is a bug in xsltproc. Before reporting a bug,
I'd like to know whether my interpretation is correct or not.

--
Vincent Lefèvre <vi*****@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Jul 20 '05 #4
"Vincent Lefevre" <vi**********@vinc17.org> wrote in message
news:20*****************@vinc17.org...
Before reporting a bug,
I'd like to know whether my interpretation is correct or not.


Nobody is going to be able to give you chapter and verse on this (as the
recent attempt illustrates). You can use "if the system identifier is a
relative URI, it must be resolved into an absolute URI using the URI of the
resource containing the entity declaration as the base URI" to support
either side of this question. However, your point of view makes sense and
the behavior you report is very counter-intuitive, so if I were you I'd file
a bug report.

If the response comes back, as I would expect, "We can't do anything because
the catalog is reporting the wrong URI," then file a bug against the
catalog. Or fix it yourself and contribute the fix.

Bob Foster
Jul 20 '05 #5
In article <ky*******************@rwcrnsc52.ops.asp.att.net >,
Bob Foster <bo********@comcast.net> wrote:
Nobody is going to be able to give you chapter and verse on this (as
the recent attempt illustrates). You can use "if the system
identifier is a relative URI, it must be resolved into an absolute
URI using the URI of the resource containing the entity declaration
as the base URI" to support either side of this question. However,
your point of view makes sense and the behavior you report is very
counter-intuitive, so if I were you I'd file a bug report.


OK, done: http://bugzilla.gnome.org/show_bug.cgi?id=122001

Thanks,

--
Vincent Lefèvre <vi*****@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Jul 20 '05 #6
Vincent Lefevre wrote:
In article <bj**********@news-sop.inria.fr>,
Philippe Poulard <Ph**************@sophia.inria.fr> wrote:

3.3 Unparsed Entities


The root node has a mapping that gives the URI for each unparsed entity
declared in the document's DTD. The URI is generated from the system
identifier and public identifier specified in the entity declaration.
The XSLT processor may use the public identifier to generate a URI for
the entity instead of the URI specified in the system identifier. If the
XSLT processor does not use the public identifier to generate the URI,
it must use the system identifier; if the system identifier is a
relative URI, it must be resolved into an absolute URI using the URI of
the resource containing the entity declaration as the base URI [RFC2396].

I know how to read the specs. :) But what if catalogs are used?
My point was that this paragraph doesn't mention catalogs; thus, the
XSLT processor should behave as if there were no catalogs (catalogs
are just a transparent way of cacheing resources). In this case, this
would mean that there is a bug in xsltproc. Before reporting a bug,
I'd like to know whether my interpretation is correct or not.


Well, in my opinion, catalogs are just a convenient way to resolve
entities, so the rules should be the same with or without catalogs, that
is to say that as the caching relies on a local file system (in your
case) the behaviour describe on the specs will be applied.

However, [in java] it is possible to an external resource to endorse a
specific BASE URI (case of XSLT) or SYSTEM ID or PUBLIC ID (case of XML)
javax.xml.transform.Source#setSystemId()
org.xml.sax.InputSource#setPublicId()
org.xml.sax.InputSource#setSystemId()

I don't really know if catalogs can do that.
See the specs, as you know how to read them :)
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Don Garrett | last post by:
I have an XML document at the root of a directory tree that contains relative URIs to resources in a directory tree. During XSLT processing, these URI's can be used without any problems to...
2
by: Andy Dingley | last post by:
I have some (somewhat ragged) HTML, and I wish to pre-process it with XSLT before putting it back onto the server. Throughout this HTML are many character entity references, such as "&ecaute;". ...
2
by: FrankStallone | last post by:
I am just getting started in XML and I made my first xml, dtd and xslt file and XML spy said they were all valid and they worked. This was the xslt doc that worked. <?xml version="1.0"...
1
by: basavaraj koti | last post by:
I need to show image using xslt Below provided in my xml and xslt. <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="../xyz.xsl"?> <Grade class="03"...
12
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I...
3
sujathaeeshan
by: sujathaeeshan | last post by:
hi all, here is xml file..... <root> <Xmltype> <owner NAME="Legal Entity 1"></owner> <LegalEntity NAME="Legal Entity 1"></LegalEntity> <lob NAME="Line Of Business 1"></lob>...
2
by: psaffrey | last post by:
I'd like to read a one-line text file using an XSLT transformation. I'm using libxslt, so I have to use XSLT 1.0. This post: http://www.stylusstudio.com/xsllist/200508/post50080.html is...
1
by: sakhawn | last post by:
hi all, I need to transform an xml file into a different format (Dublin Core schema) using xslt, file contains different records each record needs to transformed based on a unique ID (in this case...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.