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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> + JVM detection not finding JDK ... (2)
-> - stylus studio version 2011 pro... (1)
-> - WSDL 2.0 (1)
-> + Special characters in xml (2)
-> + cannot connect to mysql commun... (2)
-> + create a report from an existi... (2)
-> + Content not allowed in prolog (2)
-> + DB IInformix with database loc... (8)
-> + Stylus Report Designer (XML Re... (4)
-> - error: cos-nonambig: Content m... (1)
-> - UNIX .csv conversion and java ... (1)
-> + Nillable element, Validation e... (2)
-> + EDI Converter Error (2)
-> - CSV FILE INTO CARGO-IMP MESSAG... (1)
-> + BUG: Validation in piple will ... (2)
-> + Is there a 64-Bit Stylus Studi... (2)
-> + BUG: Read structure on SQL Ser... (3)
-> + [Customer Toyoto Motors Europe... (2)
-> - Get a schema for a JSON file (1)
-> + UNOC:4 forces converter to inp... (2)
-> - java class for xs:any elements (1)
-> + changing component separator (3)
-> + Output view disappeared (6)
-> + How to convert deeply nested X... (2)
-> + javax.net.ssl.SSLException (4)
-> + error converting .csv in a uni... (10)
-> + Menu bar disappeared (3)
-> - No Topic (1)
-> - What does "XML" stand for? So... (1)
-> - So XML is just HTML on steroid... (1)
-> + XHTML to XML conversion (2)
-> - Stylus Studio with DDTek xml c... (1)
-> + Installation fails (3)
-> + Is there a keyboard shortcut t... (2)
-> - Bug: Adding a scenario to an X... (1)
-> - Bug: Bug reporting outputs an ... (1)
-> - Tradacoms Invoice 9 Batch Quer... (1)
-> - problem with the product regis... (1)
-> + Help: Documentation... ends in... (2)
-> + How to install LIBxml2 (2)
-> - line numbers in validator outp... (1)
-> + Sharing Viollation in Stylus v... (5)
-> - support for asp.net in stylus... (1)
-> + how to use the latest java xml... (2)
-> - how to show xsd element relate... (1)
-> - Testing Stylus in a secure env... (1)
-> + How do you remove linemarkings... (3)
-> - Bug: Comment / Uncomment via C... (1)
-> + Setting escape (release) chara... (2)
-> + Xalan processor not showing up (2)
-> + Is there a keyboard shortcut t... (3)
-> - Modifying reports outside of S... (1)
-> + Run ALL Scenarios? (2)
-> + predefined macros ${ (4)
-> - TRADACOMS - EDI (1)
-> + SUM not working (3)
-> - Large xml file handling gives ... (1)
-> + 2011 Enterprise code folding f... (9)
-> + custom xml converter (3)
-> - Start Excel feter the mapping ... (1)
-> + Uninstall (2)
-> + xpath to compare two values fr... (2)
-> - xpath to compare two values fr... (1)
-> + SS2011 cannot save XML files u... (3)
-> + SS 2011 Enterprise saying 2010... (2)
-> + How to change the way whitespa... (7)
-> + Updating Relational Data Using... (4)
-> - Contract Stylus Studio help. ... (1)
-> + UTF_8 characters not displayed (6)
-> + Problem XSL to PDF ( dont reco... (2)
-> + HIPAA EDI - Looping question (4)
-> - HIPAA EDI - Looping question (1)
-> + Does XML Report support column... (2)
-> + Limited choice of XSL elements... (2)
-> + Single Source Publishing? (3)
-> - Stylus Stodio License (1)
-> - Stylus Stodio License (1)
-> + relax ng (3)
-> + having problem converting csv ... (8)
-> + error when selecting items fro... (2)
-> + CSV File to XML (3)
-> + Software registration - How to... (4)
-> - Software registration - How to... (1)
-> + .Net Saxon not supported by th... (2)
-> + How do I extend the Evaluation... (2)
-> + dst file (4)
-> + Flat File Custom XML conversio... (4)
-> + converting ascii file to xml f... (2)
-> + Evaluation Copy of Stylus Stud... (8)
-> + Batch process for soap (4)
-> + Strange error when running gen... (5)
-> + Merge Files (2)
-> + Convert cvs to XML (2)
-> + Stylus studio 2010 crashes in ... (5)
-> + excel to text (2)
-> + licence key? (2)
-> + JVM Heap error (4)
-> + How Do I clean TXT File? (2)
-> + SS Web Service Call Tester Pay... (3)
-> - SS Web Service Call Tester Mic... (1)
-- Previous [421-440] [441-460] [461-480] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Scot GreenidgeSubject: Problems using JScript with the built in parser
Author: Scot Greenidge
Date: 22 Jun 2005 10:06 PM
Hello,

I am having problems using the attached embedded JScript function within my XSLT transform. When using either the external MSXML or MSXML 4.0 parsers from within StylusStudio, the script executes without error. When attempting to use either the StylusStudio built in parser or the MSXML .NET parser, I get the following errors:

Built-in Parser:

BabbageM2ToM1.xsl (19, 3)
Object required
Src: Microsoft JScript runtime error
Line:5 Error:0 Scode:800a01a8

Any ideas on why MSXML and MSXML 4.0 consider the script correct and why the built-in parser and/or MSXML .NET fail? I have been unable to determine the root cause.



Here's the embedded JScript function:

<ms:script language="JScript" implements-prefix="usr">
<![CDATA[
function parseSubType(inType) {
var outSubType;
if (typeof(inType) == "object") {
var nodeValue = inType.item(0).childNodes[0].nodeValue;
var tempSubType = new String(nodeValue);
var index = tempSubType.lastIndexOf(".");
outSubType = tempSubType.slice(index+1);
} else {
outSubType="FAILURE-UNSUPPORTED-JSCRIPT-TYPE";
}
return outSubType;
}
]]>
</ms:script>


It is invoked within a template using:

<xsl:attribute name="xsi:type" namespace="http://www.w3.org/2001/XMLSchema-instance">
<xsl:value-of select="usr:parseSubType(@type)"/>
</xsl:attribute>



Thank you,
Scot

Postnext
Ivan PedruzziSubject: Problems using JScript with the built in parser
Author: Ivan Pedruzzi
Date: 23 Jun 2005 09:47 PM
Hi Scot,

I am able to run your script the built-in processor.
With .NET what you are seeing is a runtime error because most likely the script is trying to navigate a DOM node that doesn’t exist.

Are you sure you need a script extension?
Tell us what you are trying to do may be can done with just XSLT.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Scot GreenidgeSubject: Problems using JScript with the built in parser
Author: Scot Greenidge
Date: 24 Jun 2005 11:46 AM
Thank you for the reply Ivan.

I am pretty sure that I am navigating to a valid DOM node but will check this. As I said in my original post both the external MSXML and MSXML 4.0 parsers don't exhibit the same problem given the same data set and XSLT code.

With regard to the question of whether or not the use of an external script is required, I am trying to parse the content of an attribute node that looks something like:

<property name="foo1">
<simple type=Resource.ManagedEntity.ManagedResourceEntity.ServiceDomain>foo1</simple>
</property>

stripping of the most inherited type and using this value as an attribute of a new <xsl:element/>. I.e.

<xsl:attribute name="xsi:type">
<xsl:value-of select=parseSubType(@type)
</xsl:attribute>

I am fairly new to XSLT so there may well be a much better approach to the problem. The use of JScript seemed like the most direct path to gain the additional string parsing capability. I would welcome an alternate approach that just uses XSLT/XPath techniques.

Postnext
Ivan PedruzziSubject: Problems using JScript with the built in parser
Author: Ivan Pedruzzi
Date: 24 Jun 2005 05:03 PM
Scot,

You can definitly solve the problem using XSLT.

Assume to have in input

<?xml version="1.0"?>
<property name="foo1">
<simple type="Resource.ManagedEntity.ManagedResourceEntity.ServiceDomain">foo1</simple>
</property>


Use following XSLT 1.0 transformation

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:call-template name="lastToken">
<xsl:with-param name="value" select="/property/simple/@type"/>
</xsl:call-template>
</xsl:template>


<xsl:template name="lastToken">
<xsl:param name="value"/>
<xsl:param name="separator" select="'.'"/>
<xsl:choose>
<xsl:when test="substring-after($value, '.')">
<xsl:call-template name="lastToken">
<xsl:with-param name="value" select="substring-after($value, '.')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>


In XSLT 2.0 is even easier because of the XPath 2.0 function fn:tokenize


<?xml version='1.0'?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/04/xpath-functions">

<xsl:template match="/">
<xsl:value-of select="fn:tokenize(/property/simple/@type, '\.')[position() = last()]"/>
</xsl:template>

</xsl:stylesheet>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
Scot GreenidgeSubject: Problems using JScript with the built in parser
Author: Scot Greenidge
Date: 27 Jun 2005 12:42 PM
Thank you very much for the tutorial Ivan, I appreciate it. Yes, the solution works as you describe. Thank you as well for the pre-notice on the additional support for tokenize in XSLT 2.0.

Best Regards,
Scot

   
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.