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
Ramya NSubject: Urgent Help needed : Java functions
Author: Ramya N
Date: 25 Apr 2003 06:02 AM
Hi,

I recently installed Stylus 4.6. Finding it very useful. But I have run into a problem. I have to map 2 XMLs. The process involves using complex java functions. So , for a trial
i created a Java class with a simple function given below :

public class Functions
{
private String newData;
public String convertForm(String oldData)
{
if(oldData == "SW")
newData = "Software";
else if(oldData == "HW")
newData = "Hardware";
else if(oldData == "DV")
newData = "Developer Guide";
else if(oldData == "QA")
newData = "Testing";
else
newData = "Others";
return newData;
}
}

I want to use this function in an XML to XML mapping XSL. I registered this class Functions following the steps given in the Help Documentation (Help Menu). But when i click on the XSLT Functions in the popup, the function convertForm does not appear in the list of functions.
Any ideas??

Would appreciate a quick reply please.

Thanks in advance

Ramya.

Postnext
Ivan PedruzziSubject: RE: Urgent Help needed : Java functions
Author: Ivan Pedruzzi
Date: 25 Apr 2003 09:31 AM


Change the return type to Object

public Object convertForm(String oldData)



Ivan Pedruzzi
Progress Software
http://www.stylusstudio.com


> -----Original Message-----
> From: stylus-studio-xslt Listmanager
> [mailto:listmanager@edn.exln.com]
> Sent: Friday, April 25, 2003 6:22 AM
> To: Recipients of 'stylus-studio-xslt' suppressed
> Subject: Urgent Help needed : Java functions
>
>
> From: "Ramya N"
>
> Hi,
>
> I recently installed Stylus 4.6. Finding it very useful. But
> I have run into a problem. I have to map 2 XMLs. The process
> involves using complex java functions. So , for a trial i
> created a Java class with a simple function given below :
>
> public class Functions
> {
> private String newData;
> public String convertForm(String oldData)
> {
> if(oldData == "SW")
> newData = "Software";
> else if(oldData == "HW")
> newData = "Hardware";
> else if(oldData == "DV")
> newData = "Developer Guide";
> else if(oldData == "QA")
> newData = "Testing";
> else
> newData = "Others";
> return newData;
> }
> }
>
> I want to use this function in an XML to XML mapping XSL. I
> registered this class Functions following the steps given in
> the Help Documentation (Help Menu). But when i click on the
> XSLT Functions in the popup, the function convertForm does
> not appear in the list of functions. Any ideas??
>
> Would appreciate a quick reply please.
>
> Thanks in advance
>
> Ramya.
>
>
>
> To reply: mailto:stylus-studio-xslt.6628@edn.exln.com
> To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
> To login: http://edn.exln.com/~SSDN
>

Postnext
Rob SutherlandSubject: RE: Urgent Help needed : Java functions
Author: Rob Sutherland
Date: 25 Apr 2003 09:42 AM

Ivan,

can you explain to me the benefits of using a Java function to transform XML
to XML rather than using an XSL template to do the various transforms?

thanks.

Rob


-----Original Message-----
From: stylus-studio-xslt Listmanager [mailto:listmanager@edn.exln.com]
Sent: Friday, April 25, 2003 6:52 AM
To: Recipients of 'stylus-studio-xslt' suppressed
Subject: RE: Urgent Help needed : Java functions


From: Ivan Pedruzzi



Change the return type to Object

public Object convertForm(String oldData)



Ivan Pedruzzi
Progress Software
http://www.stylusstudio.com


> -----Original Message-----
> From: stylus-studio-xslt Listmanager
> [mailto:listmanager@edn.exln.com]
> Sent: Friday, April 25, 2003 6:22 AM
> To: Recipients of 'stylus-studio-xslt' suppressed
> Subject: Urgent Help needed : Java functions
>
>
> From: "Ramya N"
>
> Hi,
>
> I recently installed Stylus 4.6. Finding it very useful. But
> I have run into a problem. I have to map 2 XMLs. The process
> involves using complex java functions. So , for a trial i
> created a Java class with a simple function given below :
>
> public class Functions
> {
> private String newData;
> public String convertForm(String oldData)
> {
> if(oldData == "SW")
> newData = "Software";
> else if(oldData == "HW")
> newData = "Hardware";
> else if(oldData == "DV")
> newData = "Developer Guide";
> else if(oldData == "QA")
> newData = "Testing";
> else
> newData = "Others";
> return newData;
> }
> }
>
> I want to use this function in an XML to XML mapping XSL. I
> registered this class Functions following the steps given in
> the Help Documentation (Help Menu). But when i click on the
> XSLT Functions in the popup, the function convertForm does
> not appear in the list of functions. Any ideas??
>
> Would appreciate a quick reply please.
>
> Thanks in advance
>
> Ramya.
>
>
>
> To reply: mailto:stylus-studio-xslt.6628@edn.exln.com
> To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
> To login: http://edn.exln.com/~SSDN
>



To reply: mailto:stylus-studio-xslt.6630@edn.exln.com
To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
To login: http://edn.exln.com/~SSDN

Postnext
Ivan PedruzziSubject: RE: Urgent Help needed : Java functions
Author: Ivan Pedruzzi
Date: 25 Apr 2003 10:24 AM

In this trivial case there is no benefit to use a Java function, but
there are situations where you need to perform specific task like CPU
intensive calculations or database lookups where java extensions are a
great help.

Sometimes people that are not familiar with XSLT find java extensions
more intuitive. They can quickly assemble their mappings graphically and
leverage their expertise.

Java Extension functions are not part of XSLT 1.0, so implementations
could result incompatible across XSLT processors.
We try to warn our customers about portability risks they could
encounter but I forgot to do it this time.

XSLT 2.0 is supposed to shed some light on this topic.

Thanks Rob to point this out.


Ivan Pedruzzi
Progress Software
http://www.stylusstudio.com


> -----Original Message-----
> From: stylus-studio-xslt Listmanager
> [mailto:listmanager@edn.exln.com]
> Sent: Friday, April 25, 2003 10:03 AM
> To: Recipients of 'stylus-studio-xslt' suppressed
> Subject: RE: Urgent Help needed : Java functions
>
>
> From: "Rob Sutherland"
>
>
> Ivan,
>
> can you explain to me the benefits of using a Java function
> to transform XML to XML rather than using an XSL template to
> do the various transforms?
>
> thanks.
>
> Rob
>
>
> -----Original Message-----
> From: stylus-studio-xslt Listmanager [mailto:listmanager@edn.exln.com]
> Sent: Friday, April 25, 2003 6:52 AM
> To: Recipients of 'stylus-studio-xslt' suppressed
> Subject: RE: Urgent Help needed : Java functions
>
>
> From: Ivan Pedruzzi
>
>
>
> Change the return type to Object
>
> public Object convertForm(String oldData)
>
>
>
> Ivan Pedruzzi
> Progress Software
> http://www.stylusstudio.com
>
>
> > -----Original Message-----
> > From: stylus-studio-xslt Listmanager
> [mailto:listmanager@edn.exln.com]
> > Sent: Friday, April 25, 2003 6:22 AM
> > To: Recipients of 'stylus-studio-xslt' suppressed
> > Subject: Urgent Help needed : Java functions
> >
> >
> > From: "Ramya N"
> >
> > Hi,
> >
> > I recently installed Stylus 4.6. Finding it very useful. But
> > I have run into a problem. I have to map 2 XMLs. The process
> > involves using complex java functions. So , for a trial i
> > created a Java class with a simple function given below :
> >
> > public class Functions
> > {
> > private String newData;
> > public String convertForm(String oldData)
> > {
> > if(oldData == "SW")
> > newData = "Software";
> > else if(oldData == "HW")
> > newData = "Hardware";
> > else if(oldData == "DV")
> > newData = "Developer Guide";
> > else if(oldData == "QA")
> > newData = "Testing";
> > else
> > newData = "Others";
> > return newData;
> > }
> > }
> >
> > I want to use this function in an XML to XML mapping XSL. I
> > registered this class Functions following the steps given in
> > the Help Documentation (Help Menu). But when i click on the
> > XSLT Functions in the popup, the function convertForm does
> > not appear in the list of functions. Any ideas??
> >
> > Would appreciate a quick reply please.
> >
> > Thanks in advance
> >
> > Ramya.
> >
> >
> >
> > To reply: mailto:stylus-studio-xslt.6628@edn.exln.com
> > To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
> > To login: http://edn.exln.com/~SSDN
> >
>
>
>
> To reply: mailto:stylus-studio-xslt.6630@edn.exln.com
> To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
> To login: http://edn.exln.com/~SSDN
>
>
>
>
> To reply: mailto:stylus-studio-xslt.6633@edn.exln.com
> To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
> To login: http://edn.exln.com/~SSDN
>

Postnext
Minollo I.Subject: Re: Urgent Help needed : Java functions
Author: Minollo I.
Date: 25 Apr 2003 09:33 AM
You need to change the signature of the function into:
public Object convertForm(String oldData)

As stated in the documentation, the Stylus Studio XSLT processor will
recognize only method signatures whose return value is Object.

Hope this helps,
Minollo

Postnext
Rob SutherlandSubject: RE: Urgent Help needed : Java functions
Author: Rob Sutherland
Date: 25 Apr 2003 09:40 AM
Ramya,

I'm not exactly sure why you are using Java to do this.

Why don't you just use an XSLt template to do the transformation? Something
like this



Hi,

I recently installed Stylus 4.6. Finding it very useful. But I have run into
a problem. I have to map 2 XMLs. The process involves using complex java
functions. So , for a trial
i created a Java class with a simple function given below :

public class Functions
{
private String newData;
public String convertForm(String oldData)
{
if(oldData == "SW")
newData = "Software";
else if(oldData == "HW")
newData = "Hardware";
else if(oldData == "DV")
newData = "Developer Guide";
else if(oldData == "QA")
newData = "Testing";
else
newData = "Others";
return newData;
}
}

I want to use this function in an XML to XML mapping XSL. I registered this
class Functions following the steps given in the Help Documentation (Help
Menu). But when i click on the XSLT Functions in the popup, the function
convertForm does not appear in the list of functions.
Any ideas??

Would appreciate a quick reply please.

Thanks in advance

Ramya.



To reply: mailto:stylus-studio-xslt.6628@edn.exln.com
To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
To login: http://edn.exln.com/~SSDN

Postnext
Rob SutherlandSubject: RE: Urgent Help needed : Java functions
Author: Rob Sutherland
Date: 25 Apr 2003 09:50 AM
Ramya,

This is a transformation that you could do with XSL. Using an
choose...when...otherwise template.

I don't know what advantage you gain by using the Java function.

Rob

-----Original Message-----
From: stylus-studio-xslt Listmanager [mailto:listmanager@edn.exln.com]
Sent: Friday, April 25, 2003 3:22 AM
To: Recipients of 'stylus-studio-xslt' suppressed
Subject: Urgent Help needed : Java functions


From: "Ramya N"

Hi,

I recently installed Stylus 4.6. Finding it very useful. But I have run into
a problem. I have to map 2 XMLs. The process involves using complex java
functions. So , for a trial
i created a Java class with a simple function given below :

public class Functions
{
private String newData;
public String convertForm(String oldData)
{
if(oldData == "SW")
newData = "Software";
else if(oldData == "HW")
newData = "Hardware";
else if(oldData == "DV")
newData = "Developer Guide";
else if(oldData == "QA")
newData = "Testing";
else
newData = "Others";
return newData;
}
}

I want to use this function in an XML to XML mapping XSL. I registered this
class Functions following the steps given in the Help Documentation (Help
Menu). But when i click on the XSLT Functions in the popup, the function
convertForm does not appear in the list of functions.
Any ideas??

Would appreciate a quick reply please.

Thanks in advance

Ramya.



To reply: mailto:stylus-studio-xslt.6628@edn.exln.com
To start a new topic: mailto:stylus-studio-xslt@edn.exln.com
To login: http://edn.exln.com/~SSDN

Postnext
Ramya NSubject: RE: Urgent Help needed : Java functions
Author: Ramya N
Date: 26 Apr 2003 03:38 AM
Thanks a lot to all who responded to my problem.
Actually , I was searching for any function convention that has to be followed by java functions(to be used in the mapping). It was not mentioned that there was anything like that , in the Help given for Mapping XML to XML. However, after sending the mail, i stumbled on to the thing i needed (that the return type has to be 'object').

Concerning why i am using Java function for this mapping :
that was just a sample function i had written, with 4 conditions. Actually we will be having around 1000 such pairs of mapping data. This data will be stored in a text file . I cannot hardcode these values in the XSLT using choose - when -otherwise construct.

Thats why , i am using a java function.

Please let me know if there any way to access a text file /properties file directly from XSLT?

Thanks,
Ramya.

Postnext
Minollo I.Subject: RE: Urgent Help needed : Java functions
Author: Minollo I.
Date: 26 Apr 2003 03:25 PM

>...
>Please let me know if there any way to access a text file /properties file
>directly from XSLT?

....not text file; but if the information you need was in an XML document,
you could use it through the document(...) function from XSLT.

Minollo

Postnext
Lee HumphriesSubject: RE: Urgent Help needed : Java functions
Author: Lee Humphries
Date: 27 Apr 2003 07:46 PM
Yep, that's what I'd do as well.

Ramya - try setting up a global variable in the XSLT that takes the return from the document function - something like this:

<xsl:variable name="MyMap" select="document('MyMapFile.xml')"/>

Then whenever you need to get at your mapping just use the variable name followed by the rest of its path, e.g.
$MyMap/Maps/Map (where 'Maps' would be the root node).

You can also use apply-templates to pick out a bit of the map to work with e.g.
<xsl:apply-templates select="$MyMap/Maps/Map[OldData = $SomeTestValue]/>

The template to match to this apply-templates could be declared like:
<xsl:template match="Map">


Regards, Lee

Postnext
Ramya NSubject: RE: Urgent Help needed : Java functions
Author: Ramya N
Date: 28 Apr 2003 09:14 AM
Thanks a lot Lee..
That worked wonderfully well!

Two doubts:
1. Is there any limit for the size of the XML file that u can load using this method?
2. Do we have to close the file , something like document.close(), once we dont need it anymore?

Thanks,
Regards
Ramya.

Posttop
Lee HumphriesSubject: RE: Urgent Help needed : Java functions
Author: Lee Humphries
Date: 28 Apr 2003 06:58 PM
Hi Ramya,

>Two doubts:
>1. Is there any limit for the size of the
>XML file that u can load using this method?
The limits are much more to do with your hardware and the XSLT processor you happen to be using.
Basic processing (i.e. a straight line pass through a source file) don't present much of an issue for any XSLT processor. I've successfully worked with 10-100Meg files without much difficulty - apart from the processing time ;)

>2. Do we have to close the file , something
>like document.close(), once we dont need it
>anymore?
Nup. Although here's some performance notes for you.
* If you're only going to be referring to the document variable for one stage of your XSLT processing then you can declare the variable there, rather than globally. That way the document will be discarded once the processing is completed for that stage (e.g. once you exit the template or drop out of the for-each loop).
* If the document is anything other than tiny and you do need to refer to it for multiple steps in your processing then definitely set it up as a global variable. It's better to wear the memory overhead than kill your processing performance.
* Here's an alternative that you may find useful for ramping up the performance. Use the document variable to load up your source document (via another XML file - see the help) and set your map file as the source against which your XSLT will run. You can then set up a key against the map file, which will dramatically improve accessing the map file.
The apply-templates in such an instance would look like:

Unfortunately you can only set up keys against the source XML file, not any included using document(), even if they are declared globally. If you want to use keys against multiple files you need to do the trick of throwing all of the files into one container XML file and then using that container file as your source, which I've done and it works well.

Regards, Lee

 
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.