[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Requested review, xml 2 js xslt

Subject: Re: Requested review, xml 2 js xslt
From: Nathan Shaw <n8_shaw@xxxxxxxxx>
Date: Fri, 18 Oct 2002 06:44:47 -0700 (PDT)
xslt variable 0 0
After some good advice from Jeorg, I am re-submitting
my question on my xml 2 js xslt.

Basically, what I am doing is generating a js array
file that is included to provide the navigation menu
items for a drop-down menu (Hiermenus).

I chose to create a near-empty xml file (only contains
a <Root></Root> element) to parse and include 4
separate files that hold navigation information,
instead of actually parsing one of those files and
including the other 3. It just seemed cleaner to me to
do it that way, because one of the nav xml files
(news) is completely different from the other 3.
However, as this is my first stab at generating a js
file and the method I have chosen seems a bit odd, I
would love to get some comments on it.

I have pasted the relevant pieces of my xslt below and
would appreciate comments, critiques, etc.. on it.

TIA --Nate

=======================================================
<?xml version="1.0" ?>
<!--
XSLT Stylesheet for OBPR javascript navigational menus
Version 0.1
10/15/2002
Nathan Shaw (nshaw@xxxxxxxxxxx)
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" encoding="iso-8859-1"
media-type="text/plain" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*" />

<!-- read in the SectionNav xml files -->
<xsl:variable name="generalInfoNav"
select="document('../sectionnavs/SectionNav_general_info.xml')/td/table/tr/td"
/>
<xsl:variable name="funLearningNav"
select="document('../sectionnavs/SectionNav_fun_learning.xml')/td/table/tr/td"
/>
<xsl:variable name="researchProjectsNav"
select="document('../sectionnavs/SectionNav_research_projects.xml')/td/table/tr/td"
/>
<xsl:variable name="newsNav"
select="document('../../newsdata/cu_news_adminData.xml')/AdminData/Categories"
/>

<xsl:template match="/">
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="Root">
	<xsl:call-template name="generalInfoMain" />
	<xsl:call-template name="researchProjectsMain" />
	<xsl:call-template name="funLearningMain" />
	<xsl:call-template name="newsMain" />
	<xsl:call-template name="generalInfoSub" />
	<xsl:call-template name="researchProjectsSub" />
	<xsl:call-template name="funLearningSub" />
</xsl:template>

<xsl:template name="generalInfoMain">//main page
General Info array
HM_Array1 = [
[175,								//menu width
"(HM_IE) ? 253:253",				//left_position
"(HM_IE) ? 64:64",					//top_position
"#000000",							//font_color
"#ffffff",							//mouseover_font_color
"#99cc99",							//background_color
"#000000",							//mouseover_background_color
"#000000",							//border_color
"#000000",							//separator_color
0,									//top_is_permanent
0,									//top_is_horizontal
0,									//tree_is_horizontal
0,									//position_under
0,									//top_more_images_visible
0,									//tree_more_images_visible
"swap_image('main_nav_general_info_f2.gif','nav_general_info');",
//evaluate_upon_tree_show
"swap_image('main_nav_general_info.gif','nav_general_info');",
	//evaluate_upon_tree_hide
0,									//right_to_left
0,									//display_on_click
0,									//top_is_variable_width
true,								//tree_is_variable_width
],<xsl:for-each select="$generalInfoNav/a">
["<xsl:value-of select="." />","<xsl:value-of
select="@href" />",1,0,0]<xsl:if
test="not(position()=last())">,</xsl:if>
</xsl:for-each>
]
</xsl:template>

<!-- process news nav, which is stored in a completely
different format in xml than the other nav files --->
<xsl:template name="newsMain">
//main page News array
HM_Array4 = [
[175,								//menu width
"(HM_IE) ? 253:253",				//left_position
"(HM_IE) ? 64:64",					//top_position
"#ffffff",							//font_color
"#ffffff",							//mouseover_font_color
"#cc0000",							//background_color
"#000000",							//mouseover_background_color
"#000000",							//border_color
"#000000",							//separator_color
0,									//top_is_permanent
0,									//top_is_horizontal
1,									//tree_is_horizontal
1,									//position_under
0,									//top_more_images_visible
1,									//tree_more_images_visible
"swap_image('main_nav_news_f2.gif','nav_news');",	
//evaluate_upon_tree_show
"swap_image('main_nav_news.gif','nav_news');",		
//evaluate_upon_tree_hide
0,									//right_to_left
0,									//display_on_click
0,									//top_is_variable_width
true,								//tree_is_variable_width
],<xsl:for-each select="$newsNav/Category">
<xsl:variable name="currLink"
select="normalize-space(.)" />
["<xsl:value-of select="$currLink" />","<xsl:value-of
select="concat('/news/news',translate($currLink,'
','_'),'.html')" />",1,0,0]<xsl:if
test="not(position()=last())">,</xsl:if>
</xsl:for-each>
]
</xsl:template>

--2 other main templates snipped --

<xsl:template name="generalInfoSub">
//sublevel General Info array
HM_Array5 = [
[254,								//menu width
"(HM_IE) ? 0:0",					//left_position
"(HM_IE) ? 83:83",					//top_position
"#000000",							//font_color
"#ffffff",							//mouseover_font_color
"#99cc99",							//background_color
"#000000",							//mouseover_background_color
"#000000",							//border_color
"#000000",							//separator_color
0,									//top_is_permanent
0,									//top_is_horizontal
0,									//tree_is_horizontal
0,									//position_under
0,									//top_more_images_visible
0,									//tree_more_images_visible
"swap_image('sub_general_info_on.gif','sub_general_info');",
//evaluate_upon_tree_show
"swap_image('sub_general_info.gif','sub_general_info');",
	//evaluate_upon_tree_hide
0,									//right_to_left
0,									//display_on_click
0,									//top_is_variable_width
true,								//tree_is_variable_width
],<xsl:for-each select="$generalInfoNav/a">
["<xsl:value-of select="." />","<xsl:value-of
select="@href" />",1,0,0]<xsl:if
test="not(position()=last())">,</xsl:if>
</xsl:for-each>
]
</xsl:template>

--3 other sub templates snipped --

</xsl:stylesheet>
=======================================================


--- Joerg Heinicke <joerg.heinicke@xxxxxx> wrote:
> Hi Nathan,
> 
> can you rephrase your problem and show only the
> *important* code. 13 KB 
> is really to much to guess what you want or to
> refactor the code.
> 
> Regards,
> 
> Joerg
> 
> Nathan Shaw wrote:
> > Hi all. I just completed coding an xslt to create
> a js
> > file and would like comments on it, as it seems as
> if
> > there is a better/easier way to do it.
> > 
> > Right now, I am parsing a basically empty file and
> > using document() to bring in the other 4 files I
> need.
> > I tried first to parse one of those files instead
> and
> > only bring in the other 3, but it did not seem as
> > clean to me.
> > 
> > Files are pasted below and any and all comments
> are
> > appreciated!
> > 
> > --Nate (digester, appreciates cc: in reply)
> 
> <code snipped="true"/>
> 


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.