Sign Up
Search
Options
search
Chat
Help
News
Log in
Not Logged in
Home
»
Boards
»
Stylus Studio Developer Network
»
XSLT Help and Discussion
»
only embedding start tags using xsl:call template
Topic
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
next
Subject:
only embedding start tags using xsl:call template
Author:
Sushant Prabhu
Date:
01 Jan 2007 08:13 PM
Hi All
I have a scenario where in I need to embed all my current xml rendered from a xsl in a new tag.
I already have a xsl in place which is something like this
*********************************************
<xsl:template match="arts">
<tag1>
blah blah
</tag1>
<tag2>
blah blah
</tag2>
</xsl:template>
<xsl:template match="article">
<tag11>
blah blah
</tag11>
<tag22>
blah blah
</tag22>
</xsl:template>
*********************************************
and many more such xsl:template match in 1 single xsl file.
Now I have to embed each of these xsl:template output in a <parent id = "11"> & close with </parent> tag.
So I want to create something like this
**************************************
<xsl:template name="parentstart" match="parentstart">
<parent id = "11"> <!-- dynamic value-->
</xsl:template>
***************************************
and
**************************************
<xsl:template name="parentend" match="parentend">
</parent>
</xsl:template>
***************************************
I plan to interspere parent call templates at the beginning & end of each tempate match so the xsl would look like this
*********************************************
<xsl:template match="arts">
<xsl:call-template name="parentstart">
</xsl:call-template>
<tag1>
blah blah
</tag1>
<tag2>
blah blah
</tag2>
<xsl:call-template name="parentend">
</xsl:call-template>
</xsl:template>
<xsl:template match="article">
<xsl:call-template name="parentstart">
</xsl:call-template>
<tag11>
blah blah
</tag11>
<tag22>
blah blah
</tag22>
<xsl:call-template name="parentend">
</xsl:call-template>
</xsl:template>
*********************************************
So the final xml output rendered from this xsl should look like
-------------------------------------------------------------
<parent id = "11">
<tag1>
blah blah
</tag1>
<tag2>
blah blah
</tag2>
</parent>
-------------------------------------------------------------
I tried to execute the same but i am encountering TransformationException tag1 is not allowed in this position in the stylesheet.
If I remove the call templates & hard code the parent tags it works fine.
Do let me know your suggestions on the same
Regards,
top
Subject:
only embedding start tags using xsl:call template
Author:
Minollo I.
Date:
01 Jan 2007 09:20 PM
You can't have an XSLT that starts an element in a template and closes it in a different template, unless you just generate that as pure text.
If you want to keep a structure similar to what you have started, you can do something like:
<xsl:template match="arts">
<xsl:call-template name="wrapper">
<xsl:with-param name="content">
<tag1>
blah blah
</tag1>
<tag2>
blah blah>
</tag2>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="wrapper">
<xsl:param name="content"/>
<parent id="11">
<xsl:copy-of select="$content"/>
</parent>
</xsl:template>
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
Powered by
Stylus Studio
, the world's leading
XML IDE
for
XML
,
XSLT
,
XQuery
,
XML Schema
,
DTD
,
XPath
,
WSDL
,
XHTML
,
SQL/XML
, and
XML Mapping
!
Go to Conference:
Select Conference
Stylus Studio Feature Requests
Stylus Studio Technical Forum
Website Feedback
XSLT Help and Discussion
XQuery Help and Discussion
Stylus Studio FAQs
Stylus Studio Code Samples & Utilities
Stylus Studio Announcements
go
Log In Options
Username:
Password:
Site Map
|
Privacy Policy
|
Terms of Use
|
Trademarks
Stylus Scoop XML Newsletter:
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.