Hi,
I'm trying to get rid of frames as menu holder in my html-page. I'd
also like to separate the menu structure to xml and xslt. Also the
actual content is divided to xml and its corresponding stylesheet.
The idea ofcourse is to import the separate menu.xml to the
content.xslt file so the menu markup wont clutter every content.xml
page.
I can do it by just including the menu as html in the content.xslt file
or a separate imported xslt file, but how on earth could i also
describe my menu as xml? I dont have a script-capable server, just
static files.
Regards,
Imiro 4 1619 da*******@hotmail.com wrote: Hi,
I'm trying to get rid of frames as menu holder in my html-page. I'd also like to separate the menu structure to xml and xslt. Also the actual content is divided to xml and its corresponding stylesheet.
The idea of course is to import the separate menu.xml to the content.xslt file so the menu markup wont clutter every content.xml page.
Right.
I can do it by just including the menu as html in the content.xslt file or a separate imported xslt file, but how on earth could i also describe my menu as xml? I dont have a script-capable server, just static files.
If you have a menu.xml, you can open it and process all or part of it
in your mail XSLT stylesheet using the document() function.
<menu>
<main>
<item uri="foo">some label</item>
<item uri="bar">another label</item>
</main>
<special>
<item uri="blort">something else</special>
<item uri="splat">yet another</special>
</special>
</menu>
Then in your main XSLT something like:
<xsl:apply-templates select="document('main.xml')/menu/main"/>
<xsl:template match="main">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="item">
<li>
<a href="{@uri}">
<xsl:apply-templates/>
</a>
</li>
</xsl:template>
I don't understand your question about scripts. They are not involved.
///Peter
--
XML FAQ: http://xml.silmaril.ie/
Thanks for the reply Peter and nice website by the way (if using IE)
:-)
Allthough all my time's gone so far designing some details in the
menu.xslt and haven't had the chance to test you're example, I'm sure
it works. But then to make things complicated, I'd like to try and have
distinct stylesheets for the menu and the content. Now that I've delved
a bit more in the XSL-world (couple days hehe) it looks like it could
be done too, just import the menu.xslt in the main.xslt and use the
document() -function for the menu.xml. Atleast I'm hoping this will
work.
An other question I didn't find an answer to is how to get the depth of
the current element in the corresponding template? This is roughly my
xml:
<menu>
<item name="1"/>
<item name="2">
<item name="2.1"/>
<item name="2.2">
<item name="2.2.1"/>
...
</item>
</item>
<item name="3"/>
<menu>
Here the name-attribute has the structure and order info, but I'd like
to avoid that and get it automatically.
In the final html-rendition i need to create an id-attribute
corresponding to these items location in the menu-tree. For html-level
implementation reasons the items will be flat and the structure needs
to be maintained otherwise.
Anyway it would be very helpful to be able to recursively traverse the
items in the xsl-template and write the depth of the current node to
the rendition. How to do this? So far my best idea is to use the
ancestor::item together with xsl:param, not there yet though :-P
And the server-script thingy was just incase some body would suggest to
use script like jsp/asp/php...
--Imiro da*******@hotmail.com wrote: Thanks for the reply Peter and nice website by the way (if using IE)
Thanks...actually the design is homebrew and I'm no designer, and I'd
been told it doesn't look well in IE..nice to know it works somewhere!
Allthough all my time's gone so far designing some details in the menu.xslt and haven't had the chance to test you're example, I'm sure it works. But then to make things complicated, I'd like to try and have distinct stylesheets for the menu and the content.
You certainly can, but you don't need to. It's perfectly possible to
have templates for elements from different document types in the one
XSLT file. But if you want to keep them separate, you can include one
in the other at runtime with <xsl:include...
Now that I've delved a bit more in the XSL-world (couple days hehe) it looks like it could be done too, just import the menu.xslt in the main.xslt and use the document() -function for the menu.xml. Atleast I'm hoping this will work.
Yes, that's what I use for my blog, for example, to get a link menu
down the LH side from a separate file.
An other question I didn't find an answer to is how to get the depth of the current element in the corresponding template? This is roughly my xml:
<menu> <item name="1"/> <item name="2"> <item name="2.1"/> <item name="2.2"> <item name="2.2.1"/> ... </item> </item> <item name="3"/> <menu>
Here the name-attribute has the structure and order info, but I'd like to avoid that and get it automatically.
Yep, right choice. Look at <xsl:number level="multiple" format="1.1.1"/>
In the final html-rendition i need to create an id-attribute corresponding to these items location in the menu-tree. For html-level implementation reasons the items will be flat and the structure needs to be maintained otherwise.
<xsl:attribute name="id">
<xsl:text>N.</xsl:text>
<xsl:number count="item" level="multiple" format="1.1.1"/>
</xsl:attribute>
will produce an ID attribute N.1, N.2, N.2.1, N.2.2 etc
Anyway it would be very helpful to be able to recursively traverse the items in the xsl-template and write the depth of the current node to the rendition. How to do this? So far my best idea is to use the ancestor::item together with xsl:param, not there yet though :-P
xsl:number is your friend.
And the server-script thingy was just incase some body would suggest to use script like jsp/asp/php...
<gag class="spit"/> :-)
///Peter
--
XML FAQ: http://xml.silmaril.ie/
Look also at the XSL List at www.mulberrytech.com for the XSL FAQ.
Oh my, so it could be done with that tiny piece of markup ... but being
a little impatient i came up with some template trickery (which i'm
very proud of at this point;-) Hope it serves as an syntax example for
other newbs if nothing else:
<xsl:template name="item" match="item">
<xsl:param name="depth" select="0"/>
<xsl:param name="id" select="position()"/>
<xsl:text>, link=</xsl:text>
<a>
<xsl:attribute name="id">
folder<xsl:number value="$id"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="count(child::item) > 0">
<xsl:attribute name="onClick">shootEvent(this)</xsl:attribute>
<xsl:attribute name="class">mainclass</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">subclass</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@name"/>
</a>
<xsl:for-each select="child::item">
<xsl:call-template name="item">
<xsl:with-param name="depth" select="$depth + 1" />
<xsl:with-param name="id" select="concat(string($id), '.',
string(position()))" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
Does the same thing than the xsl:number with more effort, but might not
be entirely worthless since there i can access some variables more
easily if need be. No doubt i can get the same result more "elegantly",
but this seems to work good :-)
Thanks again for the advice, the learning curve is pretty steep with
all the XSL stuff!
I'll have to check the mullberry site more thoroughly with better time.
--Imiro This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: tfsquare |
last post by:
All,
I am new to XSLT and having some problems understanding the syntax of
XPath which selects nodes in the XML document. Consider this bit of
XML, which contains three outer XML elements.
...
|
by: alex |
last post by:
I'm new to xslt, and I am attempting to use it to produce a
comma-separated-value file from a large, dynamically-generated data
file formatted in xml (examples of the xml file and my xslt style...
|
by: Claudio Jolowicz |
last post by:
I need to produce an HTML page with javascript using XSLT.
Unfortunately, Mozilla has a bug that lets it crash when it encounters
document.write in an XSLT stylesheet (bugzilla# 202765). Are there...
|
by: Per Johansson |
last post by:
Is it possible to use XSLT to automatically create href links while it
formats an XML document? That is, if it finds "http://me.us/" in a
text, it adds <a href="http://me.us/">http://me.us/</a>
--...
|
by: Christopher M. Lauer |
last post by:
I have done my best to answer this question but can not find the
proper set of commands. I would like
to transform an xml file (in code behind) and display its output in a
specific html tag,...
|
by: Gordon Moore |
last post by:
Hi,
I'm new to using xml/xslt and although I can create an xml document
using the dataset.WriteXml statement, and I have created an xslt to
transform the xml into the output I want, I have to...
|
by: =?Utf-8?B?REZC?= |
last post by:
Within an XSLT transformation, I'm trying to switch the default namespace
within a section of the generated XML document to a shared namespace.
This way, the content of this section does not have...
|
by: Johan |
last post by:
How can I include one XML file into another XML file (on the client
side, in Firefox)?
I think XInclude is just what I need, but Firefox doesn't support it:...
|
by: super.raddish |
last post by:
Greetings,
I am relatively new to, what I would call, advanced XSLT/XPath and I
am after some advice from those in the know. I am attempting to figure
out a mechanism within XSLT to compare the...
|
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...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
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...
|
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 :...
|
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...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
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...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
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...
| |