xsl:import and xsl:apply_import

D

David Carlisle

The attributes on xsl:eek:utput are merged according to import precedence,
you only have one lineariser active in any given transformation.
In your case the system will output XML, which is presumably what you
want, as the method attribute on xsl:eek:utput in the first stylesheet has
higher import precedence.

the templates in transform2.xsl will still fire, but the text will be
output using XML conventions so < as &lt; this is anyway what you want
as you are outputting the child text of an element and if you generated
unquoted < or & (as the text output method would produce) the whole
result file would not be well formed XML.


Presently, the declarations in the imported xsl are ignored.

If this is so, the problem is unrelated to any of the code you have
posted, you may need to be more explict, make a small example with one
template in each stylesheet, and an explict input file and say what
output you wanted and what output you got.

David
 
S

Shiju Rajan

Hi,
I have one transformation called transform1.xsl.

transform1.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="transform2.xsl"/>
<xsl:eek:utput method="xml"/>
-------------------------------------------
<xsl:apply-imports/>
-------------------------------------------
-------------------------------------------
</xsl:template>
</xsl:stylesheet>

I have another transformation called transform2.xsl.
transform2.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
-------------------------------------------
-------------------------------------------
-------------------------------------------
</xsl:template>
</xsl:stylesheet>

I want the final XML document to have text portions wherever I have done
an apply-imports. Can you please tell me how can this be achieved? Presently,
the declarations in the imported xsl are ignored.

Regards,
Shiju,
 
S

Shiju Rajan

David Carlisle said:
The attributes on xsl:eek:utput are merged according to import precedence,
you only have one lineariser active in any given transformation.
In your case the system will output XML, which is presumably what you
want, as the method attribute on xsl:eek:utput in the first stylesheet has
higher import precedence.

the templates in transform2.xsl will still fire, but the text will be
output using XML conventions so < as < this is anyway what you want
as you are outputting the child text of an element and if you generated
unquoted < or & (as the text output method would produce) the whole
result file would not be well formed XML.


Presently, the declarations in the imported xsl are ignored.

If this is so, the problem is unrelated to any of the code you have
posted, you may need to be more explict, make a small example with one
template in each stylesheet, and an explict input file and say what
output you wanted and what output you got.

David

Hi,
Using the transforms below as examples.

transform1.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="transform2.xsl"/>
<xsl:eek:utput method="xml"/>
-------------------------------------------
<xsl:apply-imports/>
-------------------------------------------
-------------------------------------------
</xsl:template>
</xsl:stylesheet>

I have another transformation called transform2.xsl.
transform2.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
-------------------------------------------
-------------------------------------------
-------------------------------------------
</xsl:template>
</xsl:stylesheet>

The transformation transform2.xsl will generate a perl if statement where
I need to output && instead of &amp;&amp;. If I put && in that transform
then it gives a parse error therefore I have it output text.

Regards,
Shiju,
 
D

David Carlisle

Hi,
Using the transforms below as examples.


you included those in your first post, they are not examples that can be
used, they have no templates in them and have text ---- at places where
xslt doesn't allow text.

The transformation transform2.xsl will generate a perl if statement where
I need to output && instead of &amp;&amp;. If I put && in that transform
then it gives a parse error therefore I have it output text.

An XSLT stylesheet has to be well formed XML to specify && in _any_ XML
you need to write that as &amp;&amp; otherwise it won't parse as XML
and XSLt won't start. &amp;&amp; however produces a string of length 2
not a string of length 10, hiw that string is written to teh result is
independent of the way it was input. In an xml or html output methid it
will be written as &amp;&amp; in a text output method it will be
written as &&.

If you are generating an XML file then you can't have && in the result
or at least you can but it has to be quoted as &amp;&amp; If you are
generating a text file rather than XMl make sure your highest precedence
method attribute on xsl:eek:utput is text. You haven't said which of these
you are trying to do.

the output method is a property of the entire transform, conceptually it
happens _after_ the transform, specifying how to write the result tree
of nodes to a linear markup in a file.



So, if your aim is to produce an XML file containing perl codes as
element content than &amp;&amp; is the result that you need.

If your aim is to produce a text file containing perl code then you need
xsl:eek:utput method="text".

Your problem dosn't seem directly related to xsl:import at all.

David
 
D

David Carlisle

As you can see in my original post and your
answers, all your "amp; amp;" have been replaced with a &&

It's your newsreader that's at fault rather than the newsgroup itself
(probably it's trying to guess that stuff that _looks_ like html _is_
html.

however that's fairly common, over on xsl-list we normally try to write
things as "& a m p ;" spaced out to avoid that problem, sorry I forgot
to do that here.

David
 
S

Shiju Rajan

David Carlisle said:
Hi,
Using the transforms below as examples.


you included those in your first post, they are not examples that can be
used, they have no templates in them and have text ---- at places where
xslt doesn't allow text.

The transformation transform2.xsl will generate a perl if statement where
I need to output && instead of &&. If I put && in that transform
then it gives a parse error therefore I have it output text.

An XSLT stylesheet has to be well formed XML to specify && in _any_ XML
you need to write that as && otherwise it won't parse as XML
and XSLt won't start. && however produces a string of length 2
not a string of length 10, hiw that string is written to teh result is
independent of the way it was input. In an xml or html output methid it
will be written as && in a text output method it will be
written as &&.

If you are generating an XML file then you can't have && in the result
or at least you can but it has to be quoted as && If you are
generating a text file rather than XMl make sure your highest precedence
method attribute on xsl:eek:utput is text. You haven't said which of these
you are trying to do.

the output method is a property of the entire transform, conceptually it
happens _after_ the transform, specifying how to write the result tree
of nodes to a linear markup in a file.



So, if your aim is to produce an XML file containing perl codes as
element content than && is the result that you need.

If your aim is to produce a text file containing perl code then you need
xsl:eek:utput method="text".

Your problem dosn't seem directly related to xsl:import at all.

David

Hi David,
I think I got your answer from "however produces a string of length 2
not a string of length 10, " As you can see in my original post and your
answers, all your "amp; amp;" have been replaced with a && therefore it seems
this newsgroup is also using some xml to produce the output which is replacing
my "amp;amp;" with &&.

Thanks a lot.

Shiju,
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top