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
Michael KweeSubject: Problems with calling XSLT extension function from another XSLT
Author: Michael Kwee
Date: 15 Dec 2006 11:37 PM
I have a request to call a XSLT extension function from another XSLT. The XSLT extension function is support to transform external system value to internal system value for certain elements.

However, i kept hitting the following error when executing...

----------------------------------------------------------------
test_lov.xsl (34, 5): Exception calling Java extension: ; java.lang.ClassNotFoundException: d:.oexml.test_lov.test_lov2.xsl; at com.exln.stylus.CXClassLoader.findClass(CXClassLoader.java:204); at java.lang.ClassLoader.loadClass(Unknown Source); at com.exln.stylus.CXClassLoader.loadClass(CXClassLoader.java:246); at java.lang.ClassLoader.loadClass(Unknown Source);
-----------------------------------------------------------------

Please explain if there is anything wrong with the declaration and calling of the extension function ?

Please see attached for the XSLT file....


Unknowntest_lov.xsl

Postnext
Ivan PedruzziSubject: Problems with calling XSLT extension function from another XSLT
Author: Ivan Pedruzzi
Date: 16 Dec 2006 12:24 AM


In order to use EXSLT user defined functions you will need to switch to XalanJ or SAxon 6.x (click Scenario -> Processor).

You also have a template embedded inside the function body, that's illegal.


Ivan Pedruzzi
Stylus Studio Team

Postnext
Michael KweeSubject: Problems with calling XSLT extension function from another XSLT
Author: Michael Kwee
Date: 17 Dec 2006 09:15 PM
Thanks Ivan!

I have amended the function and it worked. However, with the "template match" taken out from the function, i was not able to do a template match for all the nodes starting with "LOV*" in the source XML and do a lookup for them in the EAI_Value_Map.xml using the function.

Please see the attached for the amended XSLT file and advise if this can be done.

Cheers,
Michael


Unknowntest_lov_working4.xsl

Postnext
Ivan PedruzziSubject: Problems with calling XSLT extension function from another XSLT
Author: Ivan Pedruzzi
Date: 17 Dec 2006 10:10 PM


Michael,
If want us to help you have to provide the XML input and describe what you are trying to accomplish.


Ivan Pedruzzi
Stylus Studio Team

Postnext
Brendan MulrooneySubject: Problems with calling XSLT extension function from another XSLT
Author: Brendan Mulrooney
Date: 18 Dec 2006 03:15 PM
Hi Ivan,

I currently work with Michael and can provide some additional information that will provide some background.

We are attempting the following:

Scenario exists whereby we need to transform multiple element values based on a list of values (LOV). This transformation is required for both outbound and inbound transactions.

We have 'dumped' the LOV data into an XML file which basically consists of a series of rows, see example:

<row>
<Direction>Siebel Inbound</Direction>
<Type>Back_Office_Region</Type>
<Siebel_Value>AK</Siebel_Value>
<External_System_Value>US_AK</External_System_Value>
<Comments>Alaska</Comments>
</row>


The intention is to interrogate the LOV XML via XSLT to lookup a specified node (matched on value of node name = 'Type'), then (depending on direction ie. outbound/inbound, need to be generic & bi-directional), return either the 'Siebel_Value' (Inbound) or 'External_System_Value' (Outbound) value.

We wish to retain the LOV XML as an independant file therefore when our reference data is modified (and a new file created), there will be no impact to the XSLT transformation functionality.

I have proposed the following 2 options:

Option 1.
1. Via a Template 'Match' construct (eg. <xsl:template match="LOV*/">), use an expression that will match any element in the XML. In an outbound scenario, the XML element names (those based on LOV's) will be LOV_XXX_XXX_XXX where XXX is variable. Using the sample above, the XML element would be 'LOV_Back_Office_Region'.

I understand that via 'template match', if a match is found (based on expression), it is a 'stronger' match and will override the default template match="/". Once match made, the processing instruction would need to perform the LOV 'lookup' transformation function (as described above). We will need to create this somehow. I had thought that by placing the <xsl:template match="LOV*/"> at the top of the XSLT file, it would process all elements (that match) within the XML. Can you advise if this is correct? This would also mean that an explicit 'mapping' to the element is not required (and the developer does not need to know which elements require transformation).

2. This is ok for outbound where we can control the element tag name eg. LOV_XXX_XXX_XXX. For an inbound scenario, the XML will not have the LOV prefix therefore the template match construct will not work. However, as part of the inbound transformation, we map to our own schema which will result (post transformation) in the LOV_XXX naming convention and hence at this point we could re-use our generic template match function. Is it possibe (for inbound scenario) to perform the <xsl:template match="LOV*/"> instruction almost in a 'post' processing manner? I would like to avoid passing the result of the first transformation as inputs to a second XSLT just for this purpose.


Option 2.
1. Create a specific extension function that takes the following inputs:
a. XML file - containing the LOV's
b. Type to match on within the XML eg. 'LOV_XXX_XXX_XXX'
c. Direction - to indicate inbound/outbound

This option relies on the developer creating an explicit mapping to the extension function, providing the required inputs and also being aware of the specific element name that requires LOV transformation (for both inbound & outbound).

Apologies for the essay, any assistance would be appreciated.


Regards


Brendan Mulrooney


Postnext
Michael KweeSubject: Problems with calling XSLT extension function from another XSLT
Author: Michael Kwee
Date: 18 Dec 2006 04:50 PM
I have attached the source XML together with lookup XML.

Source XML : test_a1.xml
Lookup XML : eai_value_map.xml

Thanks
Michael


Unknowntest_a1.xml


Unknowneai_value_map.xml

Posttop
Ivan PedruzziSubject: Problems with calling XSLT extension function from another XSLT
Author: Ivan Pedruzzi
Date: 18 Dec 2006 05:05 PM
If a single LOV file contains multiple rows you need to have a root element. For example

<root>
<row>
...
</row>
... more rows
</root>

The attached XSLT solution LOV.xsl takes 2 global parameters: Type and Direction ('Inbound', 'Outbound') and generates the following output

<?xml version='1.0' ?>
<root>
<LOVBack_Office_Region>AK</LOVBack_Office_Region>
</root>


Ivan Pedruzzi
Stylus Studio Team


DocumentLOV.xml


DocumentLOV.xsl

 
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.