[XSLT] [Urgent, please!] Doctype section

W

WebdoM

Hi there,

I need to transform a document in another XML format. The output file
includes a doctype section like below:

<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns">
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema">
<!ENTITY owl "http://www.w3.org/2002/07/owl">
<!ENTITY service
"http://www.daml.org/services/owl-s/1.0/Service.owl">

.....
and other declarative code:

<rdf:RDF
xmlns:rdf= "&rdf;#"
xmlns:rdfs= "&rdfs;#"
xmlns:eek:wl= "&owl;#"
....
and so on.

I can't directly include these sections in the xslt file, due a XSLT
processor error.

How can I solve the problem?

Thanks in advance!
 
M

Martin Honnen

WebdoM wrote:

I need to transform a document in another XML format. The output file
includes a doctype section like below:

<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns">
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema">
<!ENTITY owl "http://www.w3.org/2002/07/owl">
<!ENTITY service
"http://www.daml.org/services/owl-s/1.0/Service.owl">
I can't directly include these sections in the xslt file, due a XSLT
processor error.

How can I solve the problem?

XSLT 1.0 allows you to specify the public id and the system id of the
DOCTYPE declaration so you could move the above declarations into an
external DTD file and then have the XSLT processor create the
appropriate DOCTYPE declaration e.g.
<xsl:eek:utput
method="xml"
doctype-system="yourExternalDTD.dtd" />
 
W

WebdoM

In data Thu, 14 Jul 2005 19:27:39 +0200, Martin Honnen ha scritto:
WebdoM wrote:




XSLT 1.0 allows you to specify the public id and the system id of the
DOCTYPE declaration so you could move the above declarations into an
external DTD file and then have the XSLT processor create the
appropriate DOCTYPE declaration e.g.
<xsl:eek:utput
method="xml"
doctype-system="yourExternalDTD.dtd" />

Hi Martin,
thanks a lot for the good stuff.

Unfortunately, I have another similar problem.
Now my xslt appears like the following:

<snippet code>

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" doctype-system="/dtd/owl.dtd" />

<rdf:RDF
xmlns:rdf= "&rdf;#"
xmlns:rdfs= "&rdfs;#"
xmlns:eek:wl= "&owl;#"
xmlns:service= "&service;#"
xmlns:process= "&process;#"
xmlns:profile= "&profile;#"

xmlns= "&DEFAULT;#">
....
</snippet code>

and I get:

<snippet compiler message>
[Fatal Error] bt2owls.xsl:6:29: The entity "rdf" was referenced, but not
declared.
ERRORE: 'The entity "rdf" was referenced, but not declared.'
ERRORE GRAVE: 'Impossibile compilare il foglio di stile '
Exception in thread "main"
javax.xml.transform.TransformerConfigurationException: Impossibile
compilare il foglio di stile
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown
Source)
at j3e.xml.XSLTransform.main(XSLTransform.java:28)

</snippet compiler message>

What's the matter? The error message is reasonable but how can I do to
resolve?

Thanks to anyone could help me.
 
D

David Carlisle

If you reference an entity (eg &rdf;) in an XML file the you must
specify a DTD that declares the entity.

So either you need to use
<!DOCTYPE xsl:stylesheet [
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns">
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema">
<!ENTITY owl "http://www.w3.org/2002/07/owl">
<!ENTITY service
]>
<xsl:stylesheet ....

and use &rdf;

or simpler, and equivalently, you can just use


<rdf:RDF
xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
....

in your stylesheet and not declare the entity.

the result document won't use the entity reference form whether or not
use an entity reference in the stylesheet: entity references are
expanded by the xml parser before XSLT starts so the XSLT stylesheet
that us executed never has entity references.

The use of &rdf; and friends in rdf files is a shorthand for hand
writing, there is no need to use entity references in machine generated
rdf (and xslt doesn't support teh creation of entity references)

David
 
M

Martin Honnen

WebdoM wrote:

Unfortunately, I have another similar problem.
Now my xslt appears like the following:

<snippet code>

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" doctype-system="/dtd/owl.dtd" />

<rdf:RDF
xmlns:rdf= "&rdf;#"

While my suggestion with xsl:eek:utput doctype-system allows you to have a
DOCTYPE declaration in the serialized result of the XSLT transformation
it does not help you to use entity references in the stylesheet. If you
wanted to use entity references in the stylesheet then you would need to
declare the entities referenced in the stylesheet itself and you would
need to make sure you use an XML parser with your XSLT processor which
processes the (external) DTD.
But even then XSLT 1.0 does not allow you to ensure that the output
contains entity references, unless you use a processor that has some
extension to allow that.
 
W

WebdoM

In data Fri, 15 Jul 2005 11:42:36 GMT, David Carlisle ha scritto:

or simpler, and equivalently, you can just use


<rdf:RDF
xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
...

in your stylesheet and not declare the entity.

the result document won't use the entity reference form whether or not
use an entity reference in the stylesheet: entity references are
expanded by the xml parser before XSLT starts so the XSLT stylesheet
that us executed never has entity references.

The use of &rdf; and friends in rdf files is a shorthand for hand
writing, there is no need to use entity references in machine generated
rdf (and xslt doesn't support teh creation of entity references)

Thanks for clarifying my ideas. Your post has been very useful.
Now it works fine.

I think to come back for other questions about xslt&co.

Nice day at all
 
W

WebdoM

In data Fri, 15 Jul 2005 13:46:59 +0200, Martin Honnen ha scritto:
WebdoM wrote:
While my suggestion with xsl:eek:utput doctype-system allows you to have a
DOCTYPE declaration in the serialized result of the XSLT transformation
it does not help you to use entity references in the stylesheet

Thanks Martin,

I have some difficulties 'cause I am "catapulted" myself in the semantic
world (for my thesis) and many xml concepts are unknown for me. It's a very
large domain and you need to study and work a lot to acquire the right
knowledge in a short time.

So, now you know I really need this NG:)

Have a nice weekend!
 
H

HALLES

Hello !

XML could be a real semantic tool if IT behave like real semantic tools
eg : being LOGICAL !

In French we say something like (Poor translation to English since
French deals with Word/Idea [keeping closer to logic] and not as
English does Word/concept) what is understandable and clear is logic !
Same thing but a diffrent way:
Something fuzzy and hard to conceive is not logic !


All the things that work in reality are logic.
All the things that do not behave rightly in reality have a deficience
[a lack] of logic !

This being said, i will be glad to any help for an editor of XML Like
files (Tructures with logic and substructures with a family link to the
former logic) !

Well MAN ! when you receive your degree, send me a box of Davidoffs
"Demi Tasse" ;o)

Regards.

The French paradoxal thinker : HALLES
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top