File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes JAXP transformations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXP transformations" Watch "JAXP transformations" New topic

JAXP transformations


Joined: Apr 08, 2001
Posts: 12
I am using JAXP1.1 for a small application. I have some problems with the transformation part of the JAXP.
Firstly, how do I link the Source to my document's DTD, acutally the transformation is not taking value's that are defaulted in the DTD.
Secondly I doesn't recognize the character entities like © etc.
Please help.
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
For me, these looks like parser and/or XSL issues and not JAXP issues. JAXP is a convenience framework that helps you choose a parser( from a collection of available ones ) at the application level. What happens after you start parsing is beyond the control of JAXP.
Coming back to your original question, the DTD only constraints what is valid( and what is not ) in your XML document. I don't think DTD has any impact on transfomrations and output generation.
I may be wrong and I'd love to be corrected

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).

Joined: Apr 08, 2001
Posts: 12
Dear Ajith,
You haven't understood my question. I have no problems with XSL, XSLT or any other XML related standards. I have problems with the way the JAXP implements transformations. I have used JAXP for quite some time, but they upgraded it recently. The latest release of JAXP, i.e. 1.1 in addition to upgrading its SAX API, has added new transformation packages.
As you might be aware that the transformation api provides two interfaces Source and Result that abstract the concept of the Source and Result tree in XSLT, and more that that they provide specialized implementations of these for SAX, DOM and Stream sources.
I am using a SAX Source, I have made an XSL stylesheet which works fine with IE-5 and does all I want it to, but when I use the Transformer.transform() method to convert the same source it creates problems.
My question is "How do i link my DTD to the SAX Source and to the Transformer so that it picks up the values of the attributes that are defaulted in the DTD and thus are not actually part of the document being transformed?"
I hope I am explicit this time.
By the way,I am building a small appication for my personal use, actually for storing my class notes.
Aldrin John.
Mapraputa Is
Leverager of our synergies

Joined: Aug 26, 2000
Posts: 10065
I don't think DTD has any impact on transformations and output generation.
If the question is: how DTD impacts XSL transformation and XSL output generation process, the answer is �in no way� But this is not all truth. Why DTD does not affect XSLT process? Only because XSLT processor receives an input as already parsed XML document. It is on the previous stage � parsing, when DTD information may affect XML document. Conclusion: DTD information may affect XSL transformation indirectly � by changing XML document content, which then will be fed to XSLT processor. Now, how can DTD affect XML document content?
Three ways:
1. If DTD declarations contain defaults for attribute values, they will be inserted into a document.
2. If DTD contains general entity declarations, such as �copyright� referring to � symbol, references to them (&copyright; ) in an XML document will be expanded.
3. Whitespace handling. But this part is tricky and of little importance so I skip it
My question is "How do i link my DTD to the SAX Source and to the Transformer so that it picks up the values of the attributes that are defaulted in the DTD and thus are not actually part of the document being transformed?"
I have no idea how to link an external DTD with JAXP , but maybe instead you can make it internal, by including DTD in your XML document:
<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE rootElement [
<!ELEMENT myElement (#PCDATA)>
<myElement>My data...</myElement>

Of course, this will not work if more than one XML document share the same DTD.
[This message has been edited by Mapraputa Is (edited June 11, 2001).]

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet

Joined: Apr 08, 2001
Posts: 12
I think DTD does have an effect on the transformation process. Where would the transformer get the values of the attributes that are defaulted or #FIXED without refering the DTD.
Let's talk about my problem precisely. I have a date element, whose 'year' attribute is #FIXED in the DTD as 2001. Now every time I make a document, I don't give the value for the 'year' attribute, and I expect that the transformer would take it from the DTD, but it doesn't.
I had worded my problem in pretty precise terms but it seems you didn't get it.
I am really sorry, if I am confusing you guys with my silly questions.
Let me repeat it (for the last time ).
" I 'feel' the javax.xml.transform.Transformer is a non-validating processor, which is why it does not take the DTD into account when it transforms the document. What I want to know is how do I make it a validating one."
By the way there are some disparities in the namespace implementation in JAXP, it does not do exactly what the specification requires it to. Do you have any ideas in this matter. Actually, i have problems with the 'uniqueness of attributes'.
Do you know about some really good JAXP reference.

Aldrin John.

[This message has been edited by Aldrin Dsouza (edited June 17, 2001).]
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12769
I just got this email from Sun's XML announcements mailing list. Maybe the new tutorial will help you. (Incidently, I think the May 18th date is a misprint & they mean June 18, tomorrow)
"An updated version of the JAXP tutorial will be available
Monday morning, May 18th. This message describes the
1. The description of using XPath expressions to select
sets of XML nodes is now complete. You can find it at
2. The section that describes creating an XSLT stylesheet
and using it to transform XML data is not complete, but
now has a detailed-enough set of notes that a sufficiently-
determined individual could use it to get the job done.
That page is at
Coming up:
a) Work through the XSLT transformation example and
write it up. (That will finish up the content of the
JAXP tutorial.)
b) Make a PDF version of the tutorial available.
It is sorta covered in the JavaRanch Style Guide.
subject: JAXP transformations