How to make an XML declaration in xQuery and how to properly and how to reference it to a DTD?

happytree12friend
happytree12friend used Ask the Experts™
on
How can i generate the output example from below by using xQuery?

Hints: by using unescaped-data

I would like to know the solution of how to use the unescaped-data for the xml declaration and the way to generate the reference to a DTD. Thank You.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE name SYSTEM "testing.dtd">

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
Doctypes are a serialisation issue in XQuery and only supported through extensions.
Which XQuery processor are you using?
Gertone (Geert Bormans)Information Architect
Top Expert 2006
Commented:
this is what you would need for Saxon-HE Xquery 9.3

declare option saxon:output "omit-xml-declaration=no";
declare option saxon:output "doctype-system=testing.dtd";

check the manual of the product you use for "serialisation options"
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
you might find this interesting
http://www.saxonica.com/documentation/using-xquery/extensions.xml

>Hints: by using unescaped-data
this actually only makes sense when you are dealing with a bunch of parameter entities in the internal subset of the DTD
that would be a tricky beast. Then I surely need to know which XQuery engine you are using
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Author

Commented:
Currently i am using the kawa-1.9.1.jar to generate the xml output is there any possible solution for that? Thank You
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
Qexo (kawa)  is only a partial XQuery implementation.
I don't have a clue about its possibilities regarding serialisation.
As I suggested, check its manual

Why do you use Qexo? Is it mandated for a reason?
And where did you get the "hint" from

Is this homework?
If it is, please check EE regulations, and check the kawa manual yourself.
Enough new hints in this question then
Gertone (Geert Bormans)Information Architect
Top Expert 2006
Commented:
from the qexo manual:

Qexo implements the Serialization Feature. However, only some serialization parameters are settable.

about this feature:
http://www.w3.org/TR/xquery/#id-serialization-feature
with these parameters
http://www.w3.org/TR/xquery/#id-xq-serialization-parameters

I have no clue how to set these parameters in Qexo
but you have an example for Saxon,
it will be very similar,
just write a message to the Qexo people to ask how to set it
and please post afterwards here for future reference

Author

Commented:
How to defined XML declaration with xq?
And how to achieved the references DTD via kawa command line?
I execute my queries using the open-source Kawa system.

i have to include:
1. the proper XML declaration <?xml version="1.0" encoding="ISO-8859-1" ?> and
2. the reference to the DTD testing.dtd

http://www.gnu.org/software/kawa/Options.html

i have no idea to generate the first two line "XML declaration and reference DTD"...
anyone know? Thanksss....
Information Architect
Top Expert 2006
Commented:
All you need to know has been explained sofar, how hard can it be?
I asked you to do a tiny little bit of the question yourself, and you seem to fail... I am a bit dissappointed by how little effort you want to do yourself.
EE is about teaching you how to help yourself, not about doing each of your assignments up to the tiniest detail so you get your grades for free

I will try again

The reference DTD = the SYSTEM declaration (see my Saxon example earlier, it is exactly the same mechanism)

from the reference you just put in

out:doctype-system=system-identifier
    If out:doctype-system is specified then a DOCTYPE declaration is written before writing a top-level XML element, using the specified system-identifier.

please check back your reference and the above example and connect the dots yourself, this is obviously homework

about <?xml version="1.0" encoding="ISO-8859-1" ?>
this can't be done as XML I believe, I believe (from memory, no refernece) that Qexo is unable to output any other encoding but the default UTF-8,
so you need another mechanism

you could use the hint of your academic assignment now and use unescaped-data.
http://www.gnu.org/software/kawa/Formatting-XML.html
BUT BEWARE if you do use unescaped-data()
the resulting XML will have a label that says it is ISO-8859-1 encoded,
but the XML itself will be UTF-8 encoded (by default by Qexo)
There is a potential risk that you simply create XML that is NOT wellformed, as soon as you will add characters such as "é" etc

Author

Commented:
this is not an assignment...my friend ask me to do so...
i solve the xquery part...but don't know how to solve the first two line declaration...
thanks anyway~
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
well, it is all there to solve it.
welcome
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
why do you ask in the first place then
Question is answered completely, so I have to object against your request
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
made a copying error
here is the correct one

assist: http:#a35779316
assist: http:#a35783588
accept: http:#a35785001

Commented:
All,
 
Following an 'Objection' by Gertone (at http://www.experts-exchange.com/Q_27045940.html) to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
 
At this point I am going to re-start the auto-close procedure.
 
Thank you,
 
SouthMod
Community Support Moderator

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial