Hi,
I write a javascript function in xsl (UOMConversion. xsl) as follow: - <?xml version="1.0"?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-
<script language="Javascript">
-
<![CDATA[
-
var ISOUOM= new Array("KGM","MTR","LTR","CT");
-
var MESUOM= new Array("KG","M","L","KAR");
-
-
function UOMISOTOMES(UOMIn) {
-
var i;
-
var UOMOut;
-
for (i=0; i<=ISOUOM.length; i++)
-
{
-
if (UOMIn == ISOUOM[i]) {
-
UOMOut = MESUOM[i];
-
}
-
}
-
return UOMOut;
-
}
-
]]>
-
</script>
-
</xsl:stylesheet>
I would like to import above UOMConversion.x sl into a xsl (LibUserFunctio ns.xsl). I write: - <xsl:stylesheet version="1.0"
-
xmlns:xs="http://www.w3.org/2001/XMLSchema"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-
<xsl:import href="UOMConversion.xsl"/>
-
....
-
</xsl:stylesheet>
I got an error when I use LibUserFunction s.xsl to transform an xml - "Keyword xsl:stylesheet may not contain script. Error occurred during compilation of included or imported stylesheet 'file..."
Where is the problem?
Regards
maxin
15 8584 Dormilich 8,658
Recognized Expert Moderator Expert @maxin
as stated in the error message, <script> is not an allowed child element of <xsl:stylesheet > see XSL Transformations (XSLT) for the allowed elements.
I also used date function EXSLT. The date.msxsl.xsl has also some javascript as - <?xml version="1.0"?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-
xmlns:date="http://exslt.org/dates-and-times"
-
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
-
extension-element-prefixes="date msxsl">
-
-
<msxsl:script language="Javascript" implements-prefix="date">
-
<![CDATA[
-
...
-
]]>
-
</msxsl:script>
-
</xsl:stylesheet>
The different is I dont have the namespace. I don't have any problem to import date.msxsl.xsl.
Regards
maxin
Hi,
Thanks for you answer.
It seems I need the namespace. I can import the xsl file successfully. However, I still get an error in the above javascript - "Microsoft JScript runtime error Wong number of arguments or invalid property..." I attached some codes.
Here is a xml which will be transformed: -
<?xml version="1.0" encoding="UTF-8" ?>
-
<?xml-stylesheet type="text/xsl" href="LOIPRO01_2_B2MML.xsl"?>
-
<LOIPRO01>
-
<MEINS>MTR</MEINS>
-
</LOIPRO01>
-
The LOIPRO01_2_B2MM L.xsl is: -
<?xml version="1.0" encoding="UTF-8"?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xs="http://www.w3.org/2001/XMLSchema"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns="http://www.yyy.com/ad/mes/b2mt-1.0"
-
xmlns:bml="http://www.wbf.org/xml/b2mml-v02"
-
xmlns:LibUserFunctions="http://www.yyy.com/UDF/LibUserFunctions"
-
exclude-result-prefixes="xs xsl xsi LibUserFunctions">
-
-
<xsl:import href="LibUserFunctions.xsl"/>
-
-
<xsl:template match="/LOIPRO01">
-
<bml:UnitOfMeasure>
-
<xsl:call-template name="LibUserFunctions:ISOUOMToMESUOM">
-
<xsl:with-param name="UOM" select="MEINS"/>
-
</xsl:call-template>
-
</bml:UnitOfMeasure>
-
</xsl:template>
-
</xsl:stylesheet>
-
and function ISOUOMToMESUOM is in the imported xsl LibUserFunction s.xsl: -
<?xml version="1.0" encoding="UTF-8"?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xs="http://www.w3.org/2001/XMLSchema"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-
xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date"
-
xmlns:log="http://www.xxx.com"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:LibUserFunctions="http://www.yyy.com/UDF/LibUserFunctions"
-
exclude-result-prefixes="xs xsl xsi LibUserFunctions">
-
-
<xsl:import href="UOMConversion.xsl"/>
-
-
<xsl:template name="LibUserFunctions:ISOUOMToMESUOM">
-
<xsl:param name="UOM"/>
-
<xsl:value-of select="log:UOMISOTOMES($UOM)"/>
-
</xsl:template>
-
</xsl:stylesheet>
-
the function log:UOMISOTOMES is in the imported UOMConversion.x sl: -
<?xml version="1.0"?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-
xmlns:log="http://www.xxx.com"
-
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
-
-
<msxsl:script language="Javascript" implements-prefix="log">
-
<![CDATA[
-
var ISOUOM= new Array("KGM","MTR","LTR","CT");
-
var MESUOM= new Array("KG","M","L","KAR");
-
function UOMISOTOMES(UOMIn) {
-
var i;
-
var UOMOut;
-
for (i=0; i<=ISOUOM.length; i++)
-
{
-
if (UOMIn == ISOUOM[i]) {
-
UOMOut = MESUOM[i];
-
}
-
}
-
return UOMOut;
-
}
-
]]>
-
</msxsl:script>
-
</xsl:stylesheet>
-
Regards
maxin
Dormilich 8,658
Recognized Expert Moderator Expert @maxin
you have a mistake in the for loop. the length of your array is 4, thus the last index is 3. change the end condition to "i < ISOUOM.length".
tip: it is better coding style to compute the array length outside the loop. for larger arrays you get a performance advantage. (this is generally recommended for all programming languages) - l = array.length;
-
for (i=0; i<l; i++) { ... }
Hi Dormilich,
Thanks so much for your answer. I changed my codes, But I stille get the same error. The interesting is if I make the javascript as .js and import it in html. No error occurs.
Regards
maxin
The problem seems in <![CDATA[ ... ]]> of the UOMConversion.x sl. It does not like "==" in if (UOMIn == ISOUOM[i]). However, if I change it to "=", it doesnot work correctly either. Is this a special kind of javascript in CDATA?
Regards
maxin
Dormilich 8,658
Recognized Expert Moderator Expert @maxin
maybe it's time to ask why you put in the JScript this way. to me it seems like an overkill to use xsl where a simple (and working) html call would suffice.
PS: not that I'd always use the most straightforward way.........
It is not a html I will make. This xsl is used to transfer IDOC to B2MML when I import an IDOC from SAP to MES.
Dormilich 8,658
Recognized Expert Moderator Expert
just had a quick lookup of IDoc & B2MML. where does the javascript fit in, since both types are xml?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Weston C |
last post by:
I know of course that you can use <script src=""></script> in an HTML
document to include javascript code you don't want to spill all over the
page.
I'm wondering if there's a way to include other pieces of javascript
code from *within* javascript.... a la #include in C, @import in Java,
use/require in Perl, include()/require() in PHP,...
|
by: Daniel |
last post by:
I admit that I am a novice when it comes to the HTML DOM and
JavaScript. Basically, here is what I want to do:
1. Import some HTML from a remote web site
2. Parse the HTML to locate a specific tag based on font weight and
font size
3. Check the text in that tag to see if it matches a specified string
Does anyone have any ideas?
|
by: Ricardo Garcia |
last post by:
hi, how could i import a js file in another js file???
what i want is the equivalent to:
<script type="text/javascript" src="file.js"></script>
in html
Thanks
|
by: Kevin Newman |
last post by:
I've been toying with a namespace manager, and wanted to get some input.
So what do you think?
if (typeof com == 'undefined') var com = {};
if (!com.unFocus) com.unFocus = {};
com.unFocus.Namespaces = new function() {
this.register = function(namespace) {
namespace = namespace.split('.');
|
by: anonymous |
last post by:
Hey all, I sent this as a response to someone else's problem, but then I thought it might be useful to more people so I'm starting a new thread to share and discuss it.
I found a great JavaScript library (Ajile) that completely handles namespace creation *and* importing. It's amazing! Check it out @ http://ajile.iskitz.com/.
It allows...
| |
by: VMI |
last post by:
In Access, when a user's going to import a fixed-width format ascii file, a
window in the "Import Text Wizard" lets the user "mark" where in a string
one field will begin and end (with the vertical lines that can be moved with
the mouse). Can this (or something similar) be implemented in order for the
user to graphically choose which part of...
|
by: Joseph Scoccimaro |
last post by:
I am using greasemonkey to create a script that allows one to analyze a
web page. Currently I am trying to import the javascript from an
external file to add to the DOM of a web page. It is giving me this
error: Security Error: Content at http://www.google.com/ may not load or
link to...
|
by: Frits v/d Laan |
last post by:
Hi
I cannot figure out how to import an array from PHP into Javascript
MyPHPcode is like this
<?php
$i=0;
While ($i < $num) {
$PHPvar= (" $PHPvar \" $Mystring \" , ");
$i++;
|
by: Praveen |
last post by:
Have a common function in Javascript which do transform for all .xsl's.
XSL object is loaded like this.
var xslobj=new ActiveXObject("MSXML2.FreeThreadedDOMDocument.4.0");
xslobj.async = false;
xslobj.load(xslpath);
Here inserting an 'xsl:import' node to the xsl before doing transform.
This xsl contains some common templates which can be...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |