473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT with input parameter

Hello everyone,

is it possible to give a transformation a input parameter?
I want to use this parameter as a variable in my transformation.

thanks.

bye bembi
Jun 27 '08 #1
10 5760
bb*******@lycos .de wrote:
is it possible to give a transformation a input parameter?
I want to use this parameter as a variable in my transformation.
Yes, that is possible, you define a top-level xsl:param element with the
name of the parameter and then you use the API of your XSLT processor to
set that parameter before running the transformation.

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:param name="p1"/>

<xsl:template match="/">
<xsl:value-of select="$p1"/>
</xsl:template>
</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
Thank you very much.

bembi
On 16 Mai, 17:04, Martin Honnen <mahotr...@yaho o.dewrote:
bbembi...@lycos .de wrote:
is it possible to give a transformation a input parameter?
I want to use this parameter as a variable in my transformation.

Yes, that is possible, you define a top-level xsl:param element with the
name of the parameter and then you use the API of your XSLT processor to
set that parameter before running the transformation.

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:param name="p1"/>

<xsl:template match="/">
<xsl:value-of select="$p1"/>
</xsl:template>
</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #3
Hello again,

is it possible to give the XSLT a variable number of parameter and use
it in a array?
Thanks.
bye bembi

On 18 Mai, 18:28, "bbembi...@lyco s.de" <bbembi...@lyco s.dewrote:
Thank you very much.

bembi

On 16 Mai, 17:04, Martin Honnen <mahotr...@yaho o.dewrote:
bbembi...@lycos .de wrote:
is it possible to give a transformation a inputparameter?
I want to use thisparameteras a variable in my transformation.
Yes, that is possible, you define a top-level xsl:param element with the
name of theparameterand then you use the API of yourXSLTprocess or to
set thatparameterbe fore running the transformation.
* *<xsl:styleshee t
* * *xmlns:xsl="htt p://www.w3.org/1999/XSL/Transform"
* * *version="1.0">
* * *<xsl:param name="p1"/>
* * *<xsl:template match="/">
* * * *<xsl:value-of select="$p1"/>
* * *</xsl:template>
* *</xsl:stylesheet>
--
* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
Jun 27 '08 #4
bb*******@lycos .de wrote:
is it possible to give the XSLT a variable number of parameter and use
it in a array?
For the first: Parameters can have default values. Or you could pass a
parameter which your stylesheet then parses data out of.

XSLT has no concept of "arrays". Some processors will let you pass in
non-XSLT objects but the only thing you can do with them, really, is to
pass them along to extension functions.

You might get more useful answers if you told us what you're trying to
do rather than asking whether a particular approach is possible.
Jun 27 '08 #5
bb*******@lycos .de wrote:
is it possible to give the XSLT a variable number of parameter and use
it in a array?
Depending on the XSLT processor you use it might be possible to pass in
an XML document exposed as a node-set to XSLT/XPath. For instance MSXML
allows you to build and pass in an XML DOM document.
XslCompiledTran sform allows that too. See
http://msdn.microsoft.com/en-us/libr....addparam.aspx
for the .NET types you can pass in and how the translate into XPath/XSLT
types.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #6
Thanks for the answers so far.

To give you the whole story:
I want to do this: I have a XML like:
<root>
<entry type='a' />
<entry type='b' />
<entry type='c' />
</root>

Now I want to pass a variable number of types. All these will be
exported:
Example:
parameters: a, b
Output:
<root>
<entry type='a' />
<entry type='b' />
</root>

bye bembi

On 21 Mai, 15:47, "Joseph J. Kesselman" <keshlam-nos...@comcast. net>
wrote:
bbembi...@lycos .de wrote:
is it possible to give theXSLTa variable number ofparameterand use
it in a array?

For the first: Parameters can have default values. Or you could pass aparameterwhich your stylesheet then parses data out of.

XSLThas no concept of "arrays". Some processors will let you pass in
non-XSLTobjects but the only thing you can do with them, really, is to
pass them along to extension functions.

You might get more useful answers if you told us what you're trying to
do rather than asking whether a particular approach is possible.
Jun 27 '08 #7
bb*******@lycos .de wrote:
parameters: a, b
Output:
<root>
<entry type='a' />
<entry type='b' />
</root>
I'd suggest passing a single parameter which contains a delimited string
of the values you want to match, and writing the test to use it in that
form... exactly as you've shown it here.

I did a simple and sloppy version of that in part 2 of my "styling
stylesheets" article on DeveloperWorks (http://www.ibm.com/xml).
Jun 27 '08 #8
bb*******@lycos .de wrote:
To give you the whole story:
I want to do this: I have a XML like:
<root>
<entry type='a' />
<entry type='b' />
<entry type='c' />
</root>

Now I want to pass a variable number of types. All these will be
exported:
Example:
parameters: a, b
Output:
<root>
<entry type='a' />
<entry type='b' />
</root>
Which XSLT processor do you use?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #9
I am not sure which XSLT processor will be used.
The transformation will be integreated in a existing system. I think
it is saxon 8.?

bye bembi
On 21 Mai, 18:25, Martin Honnen <mahotr...@yaho o.dewrote:
bbembi...@lycos .de wrote:
To give you the whole story:
I want to do this: I have a XML like:
<root>
* <entry type='a' />
* <entry type='b' />
* <entry type='c' />
</root>
Now I want to pass a variable number of types. All these will be
exported:
Example:
parameters: a, b
Output:
<root>
* <entry type='a' />
* <entry type='b' />
</root>

WhichXSLTproces sor do you use?

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2034
by: Federico | last post by:
Hi all, I don't know if this topic is perhaps a little bit off-topic, anyway I have a strange problem in transforming an XML file in an HTML file using XSLT form a Java program written with NetBeans. I utilize the javax.xml.transform class and in the computer where I wrote the program all function perfectly, calling the input XML file, the XSLT stylesheets and setting where to write the output HTML.
8
2164
by: Maciej Wegorkiewicz | last post by:
Hi, I have small experience in XSLT processing and I have a problem which I cannot solve. Can you look at it? I have an input file containing info about bank accounts like this: (...) <acc id="1"> <balance>100</balance>
0
1077
by: resolutionsnet | last post by:
Hi, I raised as message earlier in this forum with regards to an error when preforming a XSLT transform (see bottom of this message). On further investigation I'm find that some of the XSLT file have an namespace for encoding i.e. <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:e="http://xxx.co.uk/xxx" xmlns:msxsl='urn:schemas-microsoft-com:xslt' xmlns:var='urn:var' xmlns:userJScript='urn:userJScript'
4
5744
by: gualtmacchi | last post by:
I'm processing an XML input file getting a plain text file where from M nodes I got N output lines... It's not relevant but the input file is a recordset coming from a database and the output is an EDI message set. Now I need to put into the output file also some information regarding just the output file itself and not the input one. And it cannot be expressed in terms of input information. For example I need to determine and write how...
18
2087
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to look up what each feature depends on and gerenate a text file. For example, in the following file, I would like to find out feature A depends on A1 and A2 and feature B depends on B1 and B2. And write that to a text file.
4
1929
by: shaun roe | last post by:
I should like to count the frequency of strings embedded in a longer string, space separated. Specifically, I have: <phiModule> 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 8 5 5 5 6 6 6 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 9 9 9 9 6 7 7 7 8 8 8 8 9 9 9
12
11602
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I don't want to have to use some external program or script to parse the csv first if possible
2
3100
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is my IE code - <html> <head> <title>CEL Learning</title>
0
9643
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7496
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.