At 2008-01-11 10:29 +0530, Mukul Gandhi wrote:
[1] I want to write a transform which prevents entity expansion.
The XPath data model on which XSLT is built does not represent entity
references so that any present in the input source tree cannot be
preserved for serialization in the output tree. Since the result
tree is based on the XPath data model, one cannot represent an entity
reference in the result tree as a data model abstraction.
If you want to create entity references in the result file using XSLT
2.0, you can play with serialization using xsl:output-character and
compose entity references, but since you don't know where the entity
references were in the source tree, you won't know where to compose
them in the output serialization.
For
e.g. the output of transform should be (this is an identity
transform):
<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY x "hello">
]>
<root>
<a>&x; world</a>
</root>
...
I get the output:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<a>hello world</a>
</root>
That is because that is the information found in the source
tree. The XML processor in the XSLT processor has already resolved
all aspects of syntax and has built the XPath node tree with the
information found in the source file (but not the syntax found in the
source file).
Constructs such as entity references and CDATA sections are merely
aspects of syntax, not of information.
But I want the output as specified in [1] above.
What is the solution to this problem?
Using a language other than XSLT. I believe the DOM supports entity
references.
I can use XSLT 2.0.
Not for this problem you can't.
I hope this helps.
. . . . . . . . . . . . Ken
--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--