You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kevin Ashworth <ke...@kevinashworth.com> on 2001/08/21 21:45:58 UTC

Dynamic stylesheets (Newbie question)

I currently have two XML documents, object-view.xml and object-edit.xml.
Both are identical except for one word in one line.

object-view.xml calls this stylesheet:
<?xml-stylesheet type="text/xsl" href="view.xsl"?>

while object-edit.xml calls this one:
<?xml-stylesheet type="text/xsl" href="edit.xsl"?>

It seems silly and inefficient to have two XML documents for this.  What I
want to do is have just one XML file and access these two different
renditions like this (or some other easy method):

http://servername:8080/cocoon/object.xml?mode=view
http://servername:8080/cocoon/object.xml?mode=edit

I am surprised I cannot find an answer to this problem.  I learned that
XML/XSLT can't do this alone, and then I figured Cocoon can do this, but I
have searched FAQ, archive and docs.  Am I not looking in the right place or
using the proper terms?  Any pointers appreciated.  I've got 1.8.2 installed
with Jakarta Tomcat 3.2.3.

Thanks,

--Kevin




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Dynamic stylesheets (Newbie question)

Posted by Mamadou Bobo Sylla <ma...@yahoo.com>.
--- Kevin Ashworth <ke...@kevinashworth.com>
wrote:
> I currently have two XML documents, object-view.xml
> and object-edit.xml.
> Both are identical except for one word in one line.



Since the two are identicals except for one line (by
one word), I guess you don't need two XML as you don't
need two XSL either.One XML and one XSL can handle
this job.

What you could do is to write the line in which the
two XML are different in such a way that the xml
element of that line, contains attribute having as
value the word which makes the difference between the
two lines.
For instance: Let's say I have two shirts, one blue
and the other one black.If I consider the shirt as xml
element, I can point out the difference of color like
this:
 
<shirt color="blue" >some text here</shirt>
<shirt color="black"> some other text here</shirt>

Then you'll design your XSL in this way:

IF color=blue SHOW this
IF color=black SHOW this other

In your case , maybe you could write your XML in this
way:
<Object purpose="view.xml"></Object>
<Object purpose="edit.xml"></Object>

Then your stylesheet will check if the purpose value
is view.xml, then do the "view job", else if the value
is edit.xml then do the edit job.

I hope this solve your problem.
Bobo

> object-view.xml calls this stylesheet:
> <?xml-stylesheet type="text/xsl" href="view.xsl"?>
> 
> while object-edit.xml calls this one:
> <?xml-stylesheet type="text/xsl" href="edit.xsl"?>
> 
> It seems silly and inefficient to have two XML
> documents for this.  What I
> want to do is have just one XML file and access
> these two different
> renditions like this (or some other easy method):
> 
> http://servername:8080/cocoon/object.xml?mode=view
> http://servername:8080/cocoon/object.xml?mode=edit
> 
> I am surprised I cannot find an answer to this
> problem.  I learned that
> XML/XSLT can't do this alone, and then I figured
> Cocoon can do this, but I
> have searched FAQ, archive and docs.  Am I not
> looking in the right place or
> using the proper terms?  Any pointers appreciated. 
> I've got 1.8.2 installed
> with Jakarta Tomcat 3.2.3.
> 
> Thanks,
> 
> --Kevin
> 
> 
> 
> 
>
---------------------------------------------------------------------
> Please check that your question has not already been
> answered in the
> FAQ before posting.
> <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail:
> <co...@xml.apache.org>
> For additional commands, e-mail:
> <co...@xml.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>