472,985 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 software developers and data experts.

XML elements to JavaScript Array elements Conversion

P
Hi,

I am finding it little harder to get this done, kindly help me.
I need to convert an XML file to a JavaScript file (Array) using XSLT,
1. Can I use <xsl:output method="text">?
2. I am suppose to convert the following pattern of XML to JavaScript
file like the one given below.
Input XML format:
<links>
<section1>
<name>SearchEngines</name>
<url>www.searchengines.com</url>
<section2>
<name>Google</name>
<url>www.google.com</url>
<section3>
<name>Groups</name>
<url>www.groups.google.com</url>
</section3>
<section3>
<name>Mail</name>
<url>www.gmail.com</url>
</section3>
</section2>
<section2>
<name>Yahoo</name>
<url>www.yahoo.com</url>
<section3>
<name>Photos</name>
<url>www.photos.yahoo.com</url>
</section3>
</section2>
</section1<!-- End of Section1 - I -->
<section1>
<name>Sample</name>
<url>www.sample.com</url>
<description>No section2 links are present for
this.</description>
</section1<!-- End of Section1 - II -->
<section1>
<name>Tutorials</name>
<url>www.tutorials.com</url>
<section2>
<name>XML</name>
<url>www.tutorials.com/xml</url>
<section3>
<name>XSLT</name>
<url>www.tutorials.com/xml/xslt</url>
</section3>
</section2>

</section1<!-- End of Section1 - III -->
</links>

Output JavaScript File: ( we need to make the values of the elements as
arrays, naming for Each section's array has to be like it is given
here.)

//Section1 Entries
Array1 = [
[170, 120 // Few Hardcoded values
],
["SearchEngines","www.searchengines.com",1,0,1], // few values are
hardcoded here 1,0,1
["Sample","www.sample.com",1,0,1],
["Tutorials","www.tutorials.com",1,0,1],
]

//Section2 entries of Section1 I
Array1_1 = [
[],
["Google","www.google.com",1,0,0], // few values are hardcoded here
1,0,0
["Yahoo","www.yahoo.com",1,0,0],
]

//Section2 entries of Section1 II - when description is present for
Section 1, it should be given as section 2 link as well
Array1_2 = [
[],
["No section2 links are present for this.","www.sample.com",1,0,0],
]

//Section2 entries of Section1 III
Array1_3 = [
[],
["XML","www.tutorials.com/xml",1,0,0],
]

// Section 3 entries

Array1_1_1 = [
[],
["Groups","www.groups.google.com",1,0,0], // few values are hardcoded
here 1,0,0
["Mail","www.gmail.com",1,0,0],
]

Kindly let me know, how to do this kind of conversion from XML to
JavaScript using XSLT

Thank you,

Regards,
Annbu P

Jul 7 '06 #1
1 3789
P wrote:
1. Can I use <xsl:output method="text">?
Yes.
Kindly let me know, how to do this kind of conversion from XML to
JavaScript using XSLT
There's a lot of good XSLT instructional information on the web; my
standard recommendations are the tutorials and articles on IBM's
DeveloperWorks website (http://www.ibm.com/xml) and, for the stuff that
isn't immediately obvious after reading those articles, the XSLT FAQ at
http://www.dpawson.co.uk/xsl/index.html

(Folks here, and on most mailing lists, will be much more willing to
answer specific questions than general requests that we do your homework
for you...)
Jul 7 '06 #2

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

Similar topics

18
by: lawrence | last post by:
If I'm pretty sure there is just one form on the page, can i do this? var myForm = document.forms; If I'm not sure about the form, is it safer to do this? if (document.forms) { var myForm =...
5
by: Denis Perelyubskiy | last post by:
Hello, I need to make an array of elements accross forms. My javascript skills, as evident from this question, are rather rudimentary. I tried to make an associative array and index it with...
8
by: JS | last post by:
I am trying to add an element to an array like this: var ty = ; zz = "ty"; var ab = null; zz+=""; ab = eval(zz); document.write(ab.length);
11
by: Jon Hoowes | last post by:
Hi, I have inherited some code that has some form elements (radio buttons) that are called "1", "2" etc. for example: <input name="2" type="radio" value="45"> <input name="2" type="radio"...
3
by: Newcomsas | last post by:
Hello, I'm trying to solve a problem with JS textbox array without success. I have two buttons in my page: PLUS and MINUS; at every click on PLUS a new textbox named 'dear' is generated. So, if...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
11
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
9
by: Tuxedo | last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any elements thereafter in an array in random order: var a = new...
4
by: Norman | last post by:
I am trying to find a way to implement something like: <FORM name='form1'><TABLE> server scripting loop (php), generates X (a variable number) lines with the 3 fields { <TR><TD><input...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.