Project

Profile

Help

Bug #1526

closed

Transform subelement of nested structure

Added by Todd Gochenour over 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
High
Assignee:
Sprint/Milestone:
Start date:
2012-05-07
Due date:
% Done:

100%

Estimated time:
Platforms:

Description

I have this XML:

<dataset oid="opalobj-12">

<menuitem oid="opalobj-12">

	<title>Applications</title>

	<img>/img/user1_monitor32.png</img>

	<type>submenu</type>

	<display_seq>1</display_seq>

	<id>apps</id>

	<item_title>Applications</item_title>

	<menuitem>

		<title>Labor Planning</title>

		<type>exec</type>

		<img>/img/worker32.png</img>

		<display_seq>2</display_seq>

		<id>apps_labor_management</id>

	</menuitem>

	<menuitem>

		<title>Mobile Apps</title>

		<type>exec</type>

		<img>/icon/32/laptop.png</img>

		<display_seq>3</display_seq>

		<id>apps_mobile</id>

	</menuitem>

	<menuitem>

		<title>Enterprise Architecture</title>

		<type>exec</type>

		<img>/icon/32/environment.png</img>

		<display_seq>4</display_seq>

		<id>apps_ear</id>

	</menuitem>

	<menuitem>

		<title>ERP Roadmap</title>

		<type>exec</type>

		<img>/icon/32/environment.png</img>

		<display_seq>5</display_seq>

		<id>apps_roadmap</id>

	</menuitem>

</menuitem>

<menuitem oid="opalobj-12">

	<title>Analytics</title>

	<img>/img/data_view32.png</img>

	<type>submenu</type>

	<display_seq>6</display_seq>

	<id>reports</id>

	<item_title>Analytics</item_title>

	<menuitem>

		<title>Query Tools</title>

		<type>exec</type>

		<img>/img/table_view32.png</img>

		<display_seq>7</display_seq>

		<id>reports_pivot</id>

	</menuitem>

</menuitem>

<menuitem oid="opalobj-12">

	<title>Tools</title>

	<img>/img/screwdriver32.png</img>

	<type>submenu</type>

	<display_seq>8</display_seq>

	<id>tools</id>

	<item_title>Tools</item_title>

	<menuitem>

		<title>Administration</title>

		<type>exec</type>

		<img>/img/wrench32.png</img>

		<display_seq>9</display_seq>

		<id>tools_admin</id>

	</menuitem>

	<menuitem>

		<title>Employee Search</title>

		<type>exec</type>

		<img>/img/wrench32.png</img>

		<display_seq>10</display_seq>

		<id>tools_employee_search</id>

	</menuitem>

</menuitem>

<menuitem>

	<title>Refresh</title>

	<img>/img/refresh32.png</img>

	<type>exec</type>

	<display_seq>11</display_seq>

	<id>refresh</id>

</menuitem>

<menuitem>

	<title>Logout</title>

	<img>/img/logout32.png</img>

	<type>exec</type>

	<display_seq>12</display_seq>

	<id>logout</id>

</menuitem>

I do an xpath selection in javascript:

var node = xml.selectSingleNode("//menuitem[id=reports]")

and then transform this node with an XSL template:

<xsl:stylesheet version = '1.0'	xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="html"/>

<xsl:template match="menuitem"> 

<div class="startmenuitem">

and the current node that matches the single template in this XSL is node:

	<menuitem>

		<title>Query Tools</title>

		<type>exec</type>

		<img>/img/table_view32.png</img>

		<display_seq>7</display_seq>

		<id>reports_pivot</id>

	</menuitem>

It's as if the passed in node is treated as a #document node and the default template is firing:

<xsl:template match="/">

	<xsl:apply-templates />

</xsl:template>

If I change the condition on my template from 'menuitem' to '/', then the output of the XSL is what I am expecting. Shouldn't the template matching 'menuitem' actually match the root element passed into the transformation?

Please register to edit this issue

Also available in: Atom PDF