XInclude of XML document with XSLT instruction

Questions about XML that are not covered by the other forums should go here.
tatra603
Posts: 76
Joined: Fri Sep 17, 2004 10:53 am
Location: Prague, the Czech Republic, Europe

XInclude of XML document with XSLT instruction

Post by tatra603 »

Hello!

I have XML documentA with XSLT processing_instructionA declared inside it (on the second line). Then I have XML documentB with XSLT processing_instructionB declared inside it (on the second line) with no its ow content, but XInclude element (on the third line). This XInclude element includes XML documentA as parse="xml".

But when XML documentA is included into XML documentB, XSLT processing_instruction A is not applied on XML documentA (it is not transformed before inclusion). Should documentA be transformed before inclusion or not?

I want to simulate XMLFilters as described in Xalan samples but not with Java programming. See http://xml.apache.org/xalan-j/samples.h ... xmlfilters what I want to do without Java programming (just using XSLT processor). Is it possible?)

Thank You. Stepan
tatra603
Posts: 76
Joined: Fri Sep 17, 2004 10:53 am
Location: Prague, the Czech Republic, Europe

Post by tatra603 »

In other word I want to do something like this:

xmlA -> (xmlA * xsltA) = xmlB -> (xmlB * xsltB) = xmlC

I want to parse xmlC and receive result, but I can not save xmlB into disk. The process has to be dynamic - xmlC does not now, how many steps (transformations) are among xmlA and xmlC. Such chaining XSLT transofrmations...
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XInclude of XML document with XSLT instruction

Post by sorin_ristache »

Hello,
tatra603 wrote:But when XML documentA is included into XML documentB, XSLT processing_instruction A is not applied on XML documentA (it is not transformed before inclusion). Should documentA be transformed before inclusion or not?
No, XML processing instructions should not be executed when the fragment referred using XInclude is included in the main file. An XInclude reference is resolved by the XML parser but a processing instruction is handled by the application which calls the parser after the parser finished parsing the XML document. See the definition of a processing instruction in the XML specification: "Definition: Processing instructions (PIs) allow documents to contain instructions for applications.", "PIs are not part of the document's character data, but MUST be passed through to the application.", "The PI begins with a target used to identify the application to which the instruction is directed."
tatra603 wrote:I want to simulate XMLFilters as described in Xalan samples but not with Java programming. See http://xml.apache.org/xalan-j/samples.h ... xmlfilters what I want to do without Java programming (just using XSLT processor). Is it possible?
There is no mechanism for that in XSLT. If you do not want to use Xalan in a Java application as implementation of the org.xml.sax.XMLFilter interface you have to write a Xalan extension. If you use Xalan-J it is a Java extension, if you use Xalan-C it is a C extension.

Regards,
Sorin
Post Reply