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)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Remove leading Zeros from a st... (4)
-> + how to parse a html element fo... (2)
-> + Add namespaces to target messa... (2)
-> + XSLT Transformation - insertin... (3)
-> + Convert binary xml (9)
-> + XSLT Transformation (4)
-> + Generating hyperlinks (3)
-> + XSLT to PDF problem (with JAVA... (2)
-> + how to add onclick_ with try/c... (2)
-> + Keep table in one page. xsl-fo... (4)
-> + Cannot find a matching 2-argum... (3)
-> + Creating one string from a sub... (2)
-> + XSLT: Traversing XML twice for... (6)
-> + Copy element without namespace... (5)
-> + Create dynamic elemant name (2)
-> + XSLT: Traversing XML twice for... (3)
-> + Problem including Javascript (2)
-> + Looping through attributes (4)
-> + Transform values into elements... (4)
-> + Problem with deep node copy an... (2)
-> + Comparing Dates With ASP.NET 2... (3)
-> + Converting tree structure to h... (4)
-> + Attributes to element transfor... (2)
-> + XSLT transformation (2)
-> + XSLT transformation (5)
-> + xsl:character-map not working (2)
-> + Removing duplicates entries. (2)
-> + Image issues. (2)
-> + xsl transformation (4)
-> + XSL Question (5)
-> + how to insert xml file as an n... (2)
-> + Document Function (2)
-> + convert seconds to hh:mm:ss (5)
-> + how to remove attribute while ... (3)
-> + XSL-FO question (2)
-> + EDI 997 creation. (7)
-> + Line break within a tag in XML... (2)
-> + Contact Help Needed (2)
-> + ACK 997 (2)
-> + XSLT to output XML( which conf... (11)
-> + Retrieving all nodes where a c... (6)
-> + Verifying XML and XSD within X... (4)
-> + How to validate date format in... (3)
-> + XSLT question (2)
-> + Muenchian grouping (2)
-> + How to remove specific text en... (8)
-> + If Else Condition along with L... (2)
-> + SAXON Problem (2)
-> + comapring global variable valu... (2)
-> + copying the value of xsl in va... (2)
-> + Urgent:XSLT element value sel... (2)
-> + Ignoring first element using f... (2)
-> + EDI X12 to XML (4)
-> + XSLT FOR-EACH HELP (2)
-> + Sorting Help Needed (3)
-> + XSLT help with linking (2)
-> + selecting data into node set b... (2)
-> + Watch and Variable in Debug no... (4)
-> + Transforming XML to XML - grou... (2)
-> + Saxon 9.0 B support in debug m... (2)
-> + Repeating element question (2)
-> + Newly Purchased Version Not La... (2)
-> + xsl:include not finding file (5)
-> + JAXP and XSLT 2.0 / XPATH 2.0 (2)
-> + ASP:DropDownList trigger in Xs... (2)
-> + Auto-Skip empty values (2)
-> + retrieving a javascript functi... (2)
-> + need help (2)
-> + html tag ignored (2)
-> + Quick reply needed (8)
-> + xslt to remove namespaces but ... (2)
-> - Using a WSDL definition in an ... (1)
-> + XSL logic issue for simple inp... (6)
-> + Regarding XML namespace prefix... (4)
-> + Mapper reoganizes itself. (8)
-> + XSL Substring Removal (2)
-> + Regarding XSLT logic for a sim... (3)
-> + XSLT Transform documentation (2)
-> + XSLT stack trace in case of er... (3)
-> + No New Line (2)
-> - No New Line (1)
-> + howto loop through a sequence (2)
-> + xml and xsl and whitespace in... (2)
-> + XSL Date formatting (4)
-> + XSL to XSL Mapping using custo... (4)
-> + flat xml to nested xml comvers... (4)
-> + Including schema in scenario (2)
-> + DTDs and traversing (2)
-> + Help with transformation (2)
-> + Problem running XSLT against X... (2)
-> + Carriage return in the output (5)
-> + Generating XSLT to match a sch... (3)
-> + WYSIWYG editor (2)
-> + Grouping without For-Each (3)
-> + output XML using XSLT (8)
-> + Help configuring Xalan-j proce... (8)
-> + Convert Existing HTML pages to... (2)
-> + Generating Transformation - XS... (4)
-> + DOCTYPE public and system info... (2)
-> + Using EXSLT str:tokenize funct... (5)
-- Previous [661-680] [681-700] [701-720] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Atif SarfrazSubject: Creating Arrays using XSL
Author: Atif Sarfraz
Date: 28 Nov 2001 01:07 PM
Hi,

I was wondering whether there is a way to create arrays using XSL and then pass them to XSL Templates? Just like the arguments $arg1, can we create arrays and pass them to XSL templates for processing?

An example would be to create a list of values, and pass it to a function to display it within a table.

Regards,

Atif Sarfraz

Postnext
Minollo I.Subject: Re: Creating Arrays using XSL
Author: Minollo I.
Date: 28 Nov 2001 01:56 PM
You can assign nodesets to variables/parameters; that's probably close
enough to the concept of array.

You can do something like this:
{xsl:variable
name="myArray"}{item}item1{/item}{item}item2{/item}{/xsl:variable}

The XML document fragment assigned to the variable or parameter can be as
complicated as you want.

Then you can address individual items of the array doing something like:
{xsl:value-of select="$myArray/item[2]"/}

If you are not using the Stylus Studio processors, you will have to
explicitly convert $myArray into a nodeset before being able to run an
XPath query against it; for example, using MSXML you should change it to
select="msxml:node-set($myArray)/item[2]", where msxml is the MS extension
namespace xmlns:msxml="urn:schemas-microsoft-com:xslt" (Stylus Studio will
still understand and process it).

Hope this helps,
Minollo

Postnext
Atif SarfrazSubject: Re: Creating Arrays using XSL
Author: Atif Sarfraz
Date: 30 Nov 2001 12:17 PM
Hi,

Thanks for the information regarding creating Arrays. I am attaching a sample code at the end, which creates a drop down box and selects the option as specified in an argument. Its just an example if someone wants to use it.

The code works great in Excelon, but as you mentioned that I would have to use the Microsoft parser for running it in IE. I have a couple of questions in this regards.

1- Can you tell me whether Excelon and Microsoft are following the same standards, as set by w3 for XSL draft?
2- I don't want to run into vendor locking issue. Can you shed some light on that?
3- Would it be a better approach to use transformations at Server end instead of client end, so that they are supported in all browsers?
4- Can Excelon help me in a way to create server side java code for transformation?

Sorry for too many questions.

Regards,

Atif Sarfraz




{!-- select input Template is used to automatically make the default selection in the dropdown --}
{xsl:template name="selectTemplate"}
{xsl:param name='arg1' /}

{xsl:param name='arg2' }

{options}
{option value="Choose" selected=""}Choose Your State -->{/option}
{option value="AL"}Alabama{/option}
{option value="AK"}Alaska{/option}
{option value="AZ"}Arizona{/option}
{option value="AR"}Arkansas{/option}
{option value="CA"}California{/option}
{option value="CO"}Colorado{/option}
{option value="CT"}Connecticut{/option}
{option value="DE"}Delaware{/option}
{option value="DC"}District Of Columbia{/option}
{option value="FL"}Florida{/option}
{option value="GA"}Georgia{/option}
{option value="ID"}Idaho{/option}
{option value="IL"}Illinois{/option}
{option value="IN"}Indiana{/option}
{option value="IA"}Iowa{/option}
{option value="KS"}Kansas{/option}
{option value="KY"}Kentucky{/option}
{option value="ME"}Maine{/option}
{option value="MD"}Maryland{/option}
{option value="MI"}Michigan{/option}
{option value="MN"}Minnesota{/option}
{option value="MS"}Mississippi{/option}
{option value="MO"}Missouri{/option}
{option value="MT"}Montana{/option}
{option value="NE"}Nebraska{/option}
{option value="NV"}Nevada{/option}
{option value="NH"}New Hampshire{/option}
{option value="NY"}New York{/option}
{option value="NC"}North Carolina{/option}
{option value="ND"}North Dakota{/option}
{option value="OH"}Ohio{/option}
{option value="OK"}Oklahoma{/option}
{option value="OR"}Oregon{/option}
{option value="PA"}Pennsylvania{/option}
{option value="RI"}Rhode Island{/option}
{option value="SC"}South Carolina{/option}
{option value="SD"}South Dakota{/option}
{option value="TN"}Tennessee{/option}
{option value="TX"}Texas{/option}
{option value="UT"}Utah{/option}
{option value="VT"}Vermont{/option}
{option value="VA"}Virginia{/option}
{option value="WA"}Washington{/option}
{option value="WV"}West Virginia{/option}
{option value="WI"}Wisconsin{/option}
{option value="WY"}Wyoming{/option}
{/options}
{/xsl:param}

select="msxml:node-set($myArray)/item[2]"

{select name="select2" id="State"}
{xsl:for-each select="$arg2/options"}
{xsl:for-each select="option"}
{xsl:param name='arg3' }{xsl:value-of select="." /}{/xsl:param}
{xsl:param name='arg4' }{xsl:value-of select="./@value" /}{/xsl:param}

{b}{xsl:value-of select="$arg1" /}{/b}{br/}
{xsl:value-of select="$arg3" /}{br/}
{xsl:value-of select="$arg4" /}{br/}

{xsl:if test="$arg1=$arg4"}
{option selected=""}{xsl:value-of select="$arg3" /}{/option}
{xsl:attribute name="value"}{xsl:value-of select='$arg4' /}{/xsl:attribute}
{/xsl:if}
{xsl:if test="$arg1!=$arg4"}
{option}{xsl:value-of select="$arg3" /}{/option}
{/xsl:if}


{/xsl:for-each}
{/xsl:for-each}
{/select}
{/xsl:template}


{!-- To call the template use the code for a state --}

{xsl:call-template name='selectTemplate' }
{xsl:with-param name='arg1' }FL{/xsl:with-param}
{/xsl:call-template}

Postnext
Minollo I.Subject: Re: Creating Arrays using XSL
Author: Minollo I.
Date: 30 Nov 2001 12:26 PM

>...
>1- Can you tell me whether Excelon and Microsoft are following the same
>standards, as set by w3 for XSL draft?

The XSLT 1.0 specs don't allow for document fragments to be handled like
node-sets; all the processors I know of have implemented extensions to
handle this case (like the msxml:node-set() function).

XSLT 2.0 is removing the concept of document fragments, and will allow
operations like the one you can do in Stylus Studio without the need of any
function; rather than adding our own namespace extension, we have decided
to start supporting this model now.

Both MSXML and Stylus Studio support XSLT 1.0; Stylus Studio also supports
the MSXML extensions, like the above mentioned node-set() function and
script-based extension functions.

>2- I don't want to run into vendor locking issue. Can you shed some light
>on that?

See above.

>3- Would it be a better approach to use transformations at Server end
>instead of client end, so that they are supported in all browsers?

If you want to support non-IE browsers, yes.

>4- Can Excelon help me in a way to create server side java code for
>transformation?

The eXcelon XIS product is probably what you are looking for; XIS is an XML
repository, which embeds high performance XPath/XSLT processors.
You can read more about it and download a free evaluation version from:
http://www.exceloncorp.com/platform/index.shtml


Hope this helps,
Minollo

Posttop
Adam Van den HovenSubject: Re: Creating Arrays using XSL
Author: Adam Van den Hoven
Date: 02 Jan 2002 08:34 PM
Atif,

By now you've passed this by but someone else is going to ask the same question and I feel that an answer is still valid.

Two solutions have been proposed so far, the first is to select a vendor specific behavior (msxml:node-set() or the equivalent from saxon or what ever) or two wait for XSLT 2.0 to become an implemented recommendation.

However, there is an excellent XSL1.0 compliant solution to your problem that is better than both previous choices.

In your example you want to create a nodeset linking 2 character state names with the actual name of that state. The solution you provide is to hard code the nodeset in you template. But what happens when you want to run the template in both Canada and the US? Now you need to either extend your node set or have 3 different versions of the template (you are of course going to need to support the French province names... We are bilingual up here). As we all know from times past, hard coding is a big no-no.

A better solution is to do the following:


{xsl:stylesheet}
{xsl:param name="dataFileURI"/}
{xsl:variable name="stateProvNames" select="document($dataFileURI)" /}
{xsl:stylesheet}

Now you could hard code the dataFileURI (an OK stop gap measure) or you could retrieve the file from the parameters provided at run time, or do it at a template level. If I'm building a system that will be deployed at specific locations, I'm more likely to have one config file with a well defined name that contains everything else I would need to know (including the URI for my names files).

The advantage here is that you have now loaded the data as a nodeset in a way that EVERY XSLT1.0 processor must be able to handle. You can load the documents from any valid URI, although you should be careful when using the MSXML parser on a server if you are using HTTP requests(you need to set server safe HTTP flags and the like).

Hope it helps.

Adam

   
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.