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

Requested review, xml 2 js xslt

Subject: Requested review, xml 2 js xslt
From: Nathan Shaw <n8_shaw@xxxxxxxxx>
Date: Wed, 16 Oct 2002 09:06:18 -0700 (PDT)
swap_image
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)
=========================================================
OBPRSectionNavs.xsl

<?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>

<xsl:template name="researchProjectsMain">
//main page Research &amp; Projects array
HM_Array2 = [
[175,								//menu width
"(HM_IE) ? 253:253",				//left_position
"(HM_IE) ? 64:64",					//top_position
"#000000",							//font_color
"#ffffff",							//mouseover_font_color
"#9999cc",							//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_research_projects_f2.gif','nav_research_projects');",
//evaluate_upon_tree_show
"swap_image('main_nav_research_projects.gif','nav_research_projects');",
//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="$researchProjectsNav/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>

<xsl:template name="funLearningMain">
//main page Fun &amp; Learning array
HM_Array3 = [
[175,								//menu width
"(HM_IE) ? 253:253",				//left_position
"(HM_IE) ? 64:64",					//top_position
"#000000",							//font_color
"#ffffff",							//mouseover_font_color
"#ffcc33",							//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_fun_learning_f2.gif','nav_fun_learning');",
//evaluate_upon_tree_show
"swap_image('main_nav_fun_learning.gif','nav_fun_learning');",
	//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="$funLearningNav/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>

<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>

<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>

<xsl:template name="researchProjectsSub">
//sublevel Research &amp; Projects array
HM_Array6 = [
[253,								//menu width
"(HM_IE) ? 253:253",				//left_position
"(HM_IE) ? 83:83",					//top_position
"#000000",							//font_color
"#ffffff",							//mouseover_font_color
"#9999cc",							//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
"showSelect(false);swap_image('sub_research_projects_on.gif','sub_research_projects');",
//evaluate_upon_tree_show
"showSelect(true);swap_image('sub_research_projects.gif','sub_research_projects');",
	//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="$researchProjectsNav/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>

<xsl:template name="funLearningSub">
//sublevel Fun &amp; Learning array
HM_Array7 = [
[255,								//menu width
"(HM_IE) ? 505:505",				//left_position
"(HM_IE) ? 83:83",					//top_position
"#000000",							//font_color
"#ffffff",							//mouseover_font_color
"#ffcc33",							//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
"showSelect(false);swap_image('sub_fun_learning_on.gif','sub_fun_learning');",
//evaluate_upon_tree_show
"showSelect(true);swap_image('sub_fun_learning.gif','sub_fun_learning');",
	//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="$funLearningNav/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>

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

========================================================
HM_Arrays.xml

<?xml version='1.0'?>
<Root>

</Root>
========================================================

========================================================
SectionNav_xxxx.xml
(all SectionNav_xxxx.xml files have this structure)

<td bgcolor="#99cc99" width="160">
	<table cellspacing="5" cellpadding="0" border="0">
		<tr>
			<td><a href="/general_info/what.html">What is the
OBPR?</a><br />
			<a href="/general_info/strat.html">Strategic
Vision</a><br />
			<a href="/news/news.html">Eureka! OBPR News</a><br
/>
			<a href="/general_info/pressrel.html">Press
Releases</a><br />
			<a
href="/general_info/prespublic.html">Presentations</a><br
/>
			<a
href="/general_info/prespublic.html#newsletters">Newsletters</a><br
/>
			<a href="/general_info/art.html">Articles</a><br />
			<a href="/general_info/org.html">HQ
Organization</a><br />
			<a href="/general_info/adv.html">Advisory
Boards</a><br />
			<a href="/general_info/faq.html">FAQ's</a><br />
			<img src="/common/images/shim.gif" width="160"
height="1" border="0" alt=" " /></td>
		</tr>
	</table>
</td>
========================================================

========================================================
cu_news_AdminData.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE AdminData>
<AdminData>
   <Categories>
      <Category ID="1">ISS Research Results</Category>
      <Category ID="3">Physical Sciences
Research</Category>
      <Category ID="4">Biological Sciences
Research</Category>
      <Category ID="5">OBPR Announcements</Category>
      <Category ID="6">Commercial Research</Category>
      <Category ID="7">Education</Category>
      <Category ID="8">Outreach</Category>
      <Category ID="9">Meeting
Announcements</Category>
      <Category ID="10">General</Category>
      <Category ID="11">OBPR Research
Announcements</Category>
      <Category ID="12">ISS NGO</Category>
      
   </Categories>
   <MaxItemID>193</MaxItemID>
   
</AdminData>
========================================================


__________________________________________________
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.