XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Rohit KSubject: XSL Pre processing
Author: Rohit K
Date: 09 Jul 2007 12:09 PM
I have an XSL of around 3000 lines. It is used to transform an input XML. Now the requirement is that before the XSL transforms the XML, I need to make some modification in the input XML. Like I need to update values
in 2-3 tags of the input XML before I transform it. The rest of the input XML should be as it is.
For example, suppose there are 20 tags and then a tag called <Check> and follwed by 10 more tags.

What I need is before my XSL transforms this XML, I need to update the value of <Check> tag based on some condition. The XSL which I have as of now should be applied to the output.

Input:
<tags...>
.
.
.
.
<Check>Hello</Check>
.
.
.
.
<tags>

Instead of applying XSL to above input, it should be applied to
<tags>
.
.
.
.
<Check>sorry</Check>
.
.
.
.
<tags>

The difference is that I have updated the value of the tag (Depending on a condition).
My question is where should I write this logic so that before I apply the XSL, my input XML should be modified
and the updated XML should be used.

Regards,
Rohit

Postnext
James DurningSubject: XSL Pre processing
Author: James Durning
Date: 12 Jul 2007 01:37 PM
I can immediately see 3 possible methods of doing this.
1. Do 2 transformations. One with a preprocessing XSLT, which simply copies everything, except for a Check template.

2. Add in the modification in place. This depends on the structure of your XSLT.

3. Create a temporary result variable with the value of the check nodes at the beginning, or a temporary result variable containing the new modified input XML. Then pass this variable in to be transformed.

Postnext
Rohit KSubject: XSL Pre processing
Author: Rohit K
Date: 12 Jul 2007 02:29 PM
Hi
Thanks for the reply. I have posted another thread in this forum..Just to clarify my requirements again. The XSL which I have is very big...around 3,500 lines. Also the value of the tag which I want to update has been referred at many places in the XSL.

Regards,
Rohit

Postnext
Tony LavinioSubject: XSL Pre processing
Author: Tony Lavinio
Date: 13 Jul 2007 01:19 AM
Stylus Studio lets you build pipelines of operations.
You could make the change in the first XSLT, and then
have a second one read its input and transform that.

See http://www.stylusstudio.com/xml/pipeline.html

Postnext
Rohit KSubject: XSL Pre processing
Author: Rohit K
Date: 13 Jul 2007 09:41 AM
Can I have a logic in my XSL something like:
-From start of the incoming XML to the point where <Check> appears, put it as it is in out.xml.
-Process tags between <check> and </check>
-From </check> onwards till end of XML, put it as it is in out.xml.

Postnext
Tony LavinioSubject: XSL Pre processing
Author: Tony Lavinio
Date: 16 Jul 2007 12:20 AM
Search for 'identity transformation'

Postnext
Rohit KSubject: XSL Pre processing
Author: Rohit K
Date: 16 Jul 2007 06:09 PM
Hi
Thanks a lot. I used Identity transformation and I am able to generate second XML which is same as the first one except for value of the tag I wanted to change.
Now my problem is I need to use this XSL which I have developed from my original XSL which would be used for actual transformation. This XSL uses template match="/" so I dont think my identity XSL would be invoked.
The earlier flow was something like this:
In.xml--->Orig XSL-->Out.xml
Now it would be
In.xml-->Identity XSL-->temp.xml-->Orig XSL-->Out.xml

What I am looking for is that I should apply Orig XSL to my xml even now but from my Orig XSL, it should first invoke Identity XSL and then transform.
Hope the requirement is clear. The Orig XSL uses template match="/".

Thanks.

Postnext
Tony LavinioSubject: XSL Pre processing
Author: Tony Lavinio
Date: 17 Jul 2007 04:08 PM
A test case would help. It's very hard to explain how to
merge the identity transformation with the rest of your XSLT
if you haven't shown us any of them.

Really, what is needed is an input document and both XSLTs.
Otherwise, it's just a guessing game, and time is too valuable -
for both of us.

If you want private help, you can zip the files and email them
to stylus-field-report@progress.com

Posttop
Rohit KSubject: XSL Pre processing
Author: Rohit K
Date: 03 Aug 2007 02:40 PM
Hi
Sorry was out for few days. See the actual code which I am working on is huge. But I can give a very simple example of what my exact requirement is.
I have one XML (in.xml) which is say like this:

<name>
<first>Rohit</first>
<last>Kamboj</last>
</name>

Now I have an XSL (test1.xsl), which transforms the XML to the output as shown:

<n>
<f>Rohit</f>
<l>K</l>
<t>Rohit Kamboj</t>
</n>

My XSL is working fine and it as template match="/" on top.

Now I have a requirement such that if in my incoming XML (in.xml) say if value of tag <first> is Richard then it should be changed to Richie.

So lets say I have incoming XML (in.xml) as :

<name>
<first>Richard</first>
<last>Kamboj</last>
</name>

Now my output should be:

<n>
<f>Richie</f>
<l>K</l>
<t>Richie Kamboj</t>
</n>

We do not want to change our existing XSL for that because the impact would be huge. What we have done is that we have created another XSL which does identity transformation and operates only on tag <first>.
So the output of this new XSL (test2.xsl) is:

<name>
<first>Richie</first>
<last>Kamboj</last>
</name>

Now this output should be given as the input to our original XSL (test1.xsl).

Currently we directly apply test1.xsl on in.xml. We do not want to change this. So even now, directly test1.xsl would be applied but we need to first call test2.xsl from it which does this identity transformation and then its output should be taken as the input by test1.xsl.

Hope requirement is clear.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! 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

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
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.