Re: (Easy) Passing a Variable From Sitemap to StyleSheet?
I think you're missing the concept of the cinclude. That transformer will include, yes that's what you need, but it doesn't do anything more than that. If you need parameter substitution (eg passing a parameter from sitemap to your document,session/request parameters,...) you'll need to use another component that does this. One way is to use another transformer, for example the XSLT transformer: map:generate src=../ map:transform src=settheparamstylesheet.xslt map:param name= value=/ /map:transform/ map:transform type=cinclude/ So set the parameter in the correct tags before calling the include transformer. This isn't exactly a good way to do that (well in my eyes of course, if you only want an xml with an inclusion of a particular file:), I would use a JXTemplateGenerator (docs in your distrubution under user docs/flow).With this generator you'll have access to variables such as the sitemap, request and session parameters, use this as follows: map:generate type=jx src=myfile.xml map:param name=myparam value=myvalue/ /map:transform/ map:transform type=cinclude/ with in myfile.xml: bodytag xmlns:jx=http://apache.org/cocoon/templates/jx/1.0; anything you like cinclude:include src=cocoon:/ReadMyFile/${cocoon.parameters.myparam}.xml/ /bodytag The cocoon:/ is just your protocol you want to use (here it will go through your current sitemap for a match) The 'ReadMyFile/' is a uri part to identify a pipeline (see further) The ${cocoon.parameters.myparam} is one way to access your 'myparam' parameter passed from your sitemap with the help of the JXTemplateGenerator.(here using jexl, you may also use jxpath) Thus when generating your document, the parameter will be filled in by JXTemplateGenerator and afterwards cinclude will have the correct value to use. Remember that if you want to read another file into that location (as in this example) you'll need another pipeline that matches that file and just reads in and serializes the content: eg: map:match pattern=ReadMyFile/*.xml map:generate src={1}.xml/ map:serialize type=xml/ /map:match This just reads your file (you may want to do more with that file if you like, eg another include or styling...) and the include transformer places the outcome of the pipeline at the cinclude:.. tag. (The latter way is not the only way, but seems, in this case, the more appropriate one to me) Hope this helps, Kind Regards, Jan - Original Message - From: David Swearingen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 14, 2004 4:37 AM Subject: Re: (Easy) Passing a Variable From Sitemap to StyleSheet? Ok, I see the source of the problem now. I am trying to resolve the value of a variable from within an xml document, not within the stylesheet. I'm using the xml document to collect a bunch of xml documents using cinclude. That's where I need to have the name of a file requested in the uri by the user. So the question becomes how to pass the name of a file to a cinclude:include directive inside an xml document, if that makes sense. I will say that this user group is extremely helpful and courteous, the Cocoon platform is awesome, and I hope to be able to give back when I learn enough to contribute. David --- Jorg Heymans [EMAIL PROTECTED] wrote: in the sitemap you do map:transform blah... map:parameter name=myparam value={1}/ /map:transform then in your stylesheet do xsl:param name=myparam/ David Swearingen wrote: I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. Specifically, I have {1} defined in the sitemap, which is the basename of a file, and I want to refer to this filename in a stylesheet that's called by a transformer. I'm then going to reference this filename in the src attribute of a cinclude:include tag in the stylesheet. Need to know a) how to define it in sitemap and b) how to retrieve it in stylesheet. Thanks, David __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: (Easy) Passing a Variable From Sitemap to StyleSheet?
Just one other thing (I kinda forgot this;): You keep mentioning XSLT, but never really used it? Your pipeline was: map:match pattern=cinc2/*.html map:generate src=cinc2/template.xml/ map:transform type=cinclude map:parameter name=requestedfile value={1}/ /map:transform Here you're reading a file as XML and directly use your cinclude transformer. Hence no XSLT transformer ever comes in the picture! Keep in mind that if you want to use XSLT , use the transformer to do this, if you only inteded to read a file and transform it you might want to use this: map:generate src={1}.xml/ map:transform src=mystyle.xsl/ map:serialize/ The default transformer (normally this would be the XSLT, if not, use type=xslt, or the name used in defining that transformer, above in your main sitemap) will be used on your file that will only be known at runtime. Kind Regards, Jan - Original Message - From: Steve Schwarz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 14, 2004 5:36 AM Subject: Re: (Easy) Passing a Variable From Sitemap to StyleSheet? David You can't do it directly within the document. But maybe you just need to think about the problem a little differently. Remember you don't need this aggregate document to physically exist. It just needs to be assembled at some point in your pipeline. So I'd use a stylesheet to get what you. Often you can structure your stylesheet(s) as a general template into which you pass params to configure the included subelements. So you might have a simple document (say a table layout template for your page) and use the pipeline to pass the configuration information to the stylesheet that modifies your basic document. I do this with a single style sheet into which I pass params to cinclude the various fixed and variable content of each page's layout. HTH, Steve Ok, I see the source of the problem now. I am trying to resolve the value of a variable from within an xml document, not within the stylesheet. I'm using the xml document to collect a bunch of xml documents using cinclude. That's where I need to have the name of a file requested in the uri by the user. So the question becomes how to pass the name of a file to a cinclude:include directive inside an xml document, if that makes sense. _ Get rid of annoying pop-up ads with the new MSN Toolbar - FREE! http://toolbar.msn.com/go/onm00200414ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: (Easy) Passing a Variable From Sitemap to StyleSheet?
I posted earlier this week about needing to pass a variable from the sitemap to a stylesheet, and I understand how to do this, but I'm getting a weird error now. [NOT SURE HOW TO ESCAPE HTML FOR POSTS TO MAILING LIST.] I'm setting the variable in the sitemap as follows: map:match pattern=cinc2/*.html map:generate src=cinc2/template.xml/ map:transform type=cinclude map:parameter name=requestedfile value={1}/ /map:transform ... My file template.xml WORKS when hard-coded (cheating) with a filename, as follows: ... thebody cinclude:include src=cinc2/mybody.xml/ /thebody ... but in reality I need the filename parameterized as follows: ... xsl:param name=requestedfile/ ... thebody cinclude:includexsl:attribute name=srcxsl:value-of select=$requestedfile//xsl:attribute/cinclude:include /thebody ... This throws an error as follows: org.apache.cocoon.ProcessingException: Failed to execute pipeline.: org.xml.sax.SAXException: Missing 'src' attribute on cinclude:include element I can't even get this to work, as a test, where I hard-code the attribute value: thebody cinclude:includexsl:attribute name=srccinc2/mybody.xml/xsl:attribute/cinclude:include /thebody Thanks for any assistance. David --- Philipp Burkert [EMAIL PROTECTED] wrote: Hi, I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. first you have to handle the parameter to the transformer within the sitemap. ---sitemap-- map:match pattern=*/show.html map:generate src=xmldb:xindice-embed:///db/beschlusslage// map:transform type=xslt src=xslt/antrag2html.xslt map:parameter name=oid value={1}/ /map:transform Then you have to - declare the parameter in the xslt - and output it later with the $varname syntax ---xslt-- xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:output method=xml version=1.0 encoding=UTF-8 indent=yes/ xsl:param name=oid/ ... xsl:template match=meta name=antrag xsl:value-of select=$oid/ ... Hope that helps PHILIPP BURKERT [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: (Easy) Passing a Variable From Sitemap to StyleSheet?
David I think you want: ... xsl:param name=requestedfile/ ... thebody cinclude:include src={$requestedfile}/ /thebody ... I highly recommend Michael Kay's XSLT 2nd Edition Hope this helps Steve _ Tax headache? MSN Money provides relief with tax tips, tools, IRS forms and more! http://moneycentral.msn.com/tax/workshop/welcome.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: (Easy) Passing a Variable From Sitemap to StyleSheet?
Ok, I see the source of the problem now. I am trying to resolve the value of a variable from within an xml document, not within the stylesheet. I'm using the xml document to collect a bunch of xml documents using cinclude. That's where I need to have the name of a file requested in the uri by the user. So the question becomes how to pass the name of a file to a cinclude:include directive inside an xml document, if that makes sense. I will say that this user group is extremely helpful and courteous, the Cocoon platform is awesome, and I hope to be able to give back when I learn enough to contribute. David --- Jorg Heymans [EMAIL PROTECTED] wrote: in the sitemap you do map:transform blah... map:parameter name=myparam value={1}/ /map:transform then in your stylesheet do xsl:param name=myparam/ David Swearingen wrote: I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. Specifically, I have {1} defined in the sitemap, which is the basename of a file, and I want to refer to this filename in a stylesheet that's called by a transformer. I'm then going to reference this filename in the src attribute of a cinclude:include tag in the stylesheet. Need to know a) how to define it in sitemap and b) how to retrieve it in stylesheet. Thanks, David __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: (Easy) Passing a Variable From Sitemap to StyleSheet?
David You can't do it directly within the document. But maybe you just need to think about the problem a little differently. Remember you don't need this aggregate document to physically exist. It just needs to be assembled at some point in your pipeline. So I'd use a stylesheet to get what you. Often you can structure your stylesheet(s) as a general template into which you pass params to configure the included subelements. So you might have a simple document (say a table layout template for your page) and use the pipeline to pass the configuration information to the stylesheet that modifies your basic document. I do this with a single style sheet into which I pass params to cinclude the various fixed and variable content of each page's layout. HTH, Steve Ok, I see the source of the problem now. I am trying to resolve the value of a variable from within an xml document, not within the stylesheet. I'm using the xml document to collect a bunch of xml documents using cinclude. That's where I need to have the name of a file requested in the uri by the user. So the question becomes how to pass the name of a file to a cinclude:include directive inside an xml document, if that makes sense. _ Get rid of annoying pop-up ads with the new MSN Toolbar FREE! http://toolbar.msn.com/go/onm00200414ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
(Easy) Passing a Variable From Sitemap to StyleSheet?
I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. Specifically, I have {1} defined in the sitemap, which is the basename of a file, and I want to refer to this filename in a stylesheet that's called by a transformer. I'm then going to reference this filename in the src attribute of a cinclude:include tag in the stylesheet. Need to know a) how to define it in sitemap and b) how to retrieve it in stylesheet. Thanks, David __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: (Easy) Passing a Variable From Sitemap to StyleSheet?
Hi, I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. first you have to handle the parameter to the transformer within the sitemap. ---sitemap-- map:match pattern=*/show.html map:generate src=xmldb:xindice-embed:///db/beschlusslage// map:transform type=xslt src=xslt/antrag2html.xslt map:parameter name=oid value={1}/ /map:transform Then you have to - declare the parameter in the xslt - and output it later with the $varname syntax ---xslt-- xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:output method=xml version=1.0 encoding=UTF-8 indent=yes/ xsl:param name=oid/ ... xsl:template match=meta name=antrag xsl:value-of select=$oid/ ... Hope that helps PHILIPP BURKERT [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: (Easy) Passing a Variable From Sitemap to StyleSheet? - One complication
Indeed I can use the variable in the stylesheet as described below by Philip but I failed to anticipate that I have to use the variable INSIDE of another tag, that is, I have a variable foo that represents a filename and I have to use it as follows: [cinclude:include src=foo.xml] I'm assuming I can't nest a xsl:value-of tag inside of a cinclude:include tag...how would I render this value in this manner? Thanks, David --- Philipp Burkert [EMAIL PROTECTED] wrote: Hi, I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. first you have to handle the parameter to the transformer within the sitemap. ---sitemap-- map:match pattern=*/show.html map:generate src=xmldb:xindice-embed:///db/beschlusslage// map:transform type=xslt src=xslt/antrag2html.xslt map:parameter name=oid value={1}/ /map:transform Then you have to - declare the parameter in the xslt - and output it later with the $varname syntax ---xslt-- xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:output method=xml version=1.0 encoding=UTF-8 indent=yes/ xsl:param name=oid/ ... xsl:template match=meta name=antrag xsl:value-of select=$oid/ ... Hope that helps PHILIPP BURKERT [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: (Easy) Passing a Variable From Sitemap to StyleSheet? - One complication
Hi David. This is more of an XSLT question now really, if I understand you correctly. You should use attribute value templates (i.e. curly braces): xsl:variable name=foo/ ... cinclude:include src={$foo}/ You could indeed use xsl:value-of, like this: cinclude:include xsl:attribute name=src xsl:value-of select=$foo/ /xsl:attribute /cinclude:include ... which is a bit wordy. The attribute value template approach above is functionally identical - it's just a handy shorthand syntax. Cheers Con -Original Message- From: David Swearingen [mailto:[EMAIL PROTECTED] Sent: Monday, 12 April 2004 12:21 To: [EMAIL PROTECTED] Subject: RE: (Easy) Passing a Variable From Sitemap to StyleSheet? - One complication Indeed I can use the variable in the stylesheet as described below by Philip but I failed to anticipate that I have to use the variable INSIDE of another tag, that is, I have a variable foo that represents a filename and I have to use it as follows: [cinclude:include src=foo.xml] I'm assuming I can't nest a xsl:value-of tag inside of a cinclude:include tag...how would I render this value in this manner? Thanks, David --- Philipp Burkert [EMAIL PROTECTED] wrote: Hi, I thought this would be easy...I'm trying to pass a variable defined in the Sitemap, and retrieve it in the Stylesheet. first you have to handle the parameter to the transformer within the sitemap. ---sitemap-- map:match pattern=*/show.html map:generate src=xmldb:xindice-embed:///db/beschlusslage// map:transform type=xslt src=xslt/antrag2html.xslt map:parameter name=oid value={1}/ /map:transform Then you have to - declare the parameter in the xslt - and output it later with the $varname syntax ---xslt-- xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:output method=xml version=1.0 encoding=UTF-8 indent=yes/ xsl:param name=oid/ ... xsl:template match=meta name=antrag xsl:value-of select=$oid/ ... Hope that helps PHILIPP BURKERT [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]