473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Help/Advice with XSL / XPath needed

Hi,

I am trying to output certain nodes inside another. I have an xml
template with field definitions for a form, and this includes
textfields, labels, checkboxes etc plus fieldssets. I defined them
like
this:
XML SNIPPET >>>> <fields>
<field>
<name>lAccount_Num</name>
<id>lAccount_Num</id>
<legend />
<caption>Account Number:</caption>
<type>label</type>
<size />
<style>LEFT: 17px; WIDTH: 112px; POSITION: absolute; TOP: 35px;
HEIGHT:
18px</style>
<FOR>tAccount_Num</FOR>
<maxLength />
<parentFieldSet>fstFields</parentFieldSet>
<value />
</field>

....

<field>
<name>lEnabled</name>
<id>lEnabled</id>
<caption>Enabled:</caption>
<legend />
<type>label</type>
<size />
<style>LEFT: 330px; WIDTH: 120px; POSITION: absolute; TOP: 100px;
HEIGHT: 18px</style>
<FOR>chEnable</FOR>
<parentFieldSet />
<maxLength />
<value />
</field>

....

<field>
<name>fstFields</name>
<id>fstFields</id>
<legend>Account Date</legend>
<caption />
<type>fieldset</type>
<size />
<style>LEFT: 8px; WIDTH: 484px; POSITION: absolute; TOP: 12px; HEIGHT:
124px</style>
<FOR />
<parentFieldSet>fstFields</parentFieldSet>
<maxLength />
<value />
</field>
</fields>
<<<<< END XML SNIPPET <<<

so you can see I have a field nodes with a defined parentFieldSet, a
field nodes with no defined fieldset, and a fieldset node.

What I want is to use an XPath expresion in my match / apply-templates
to output the start tag of the FieldSet, then go and find all the
nodes
with that parentFieldSet name defined, then output the end tag of the
fieldset, following that we do the next fieldset (if any) and finally
output all the fields with no parentFieldSet defined.

Here is my XSL so far: XSL >>>>

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" version="1.0" omit-xml-declaration="no"
standalone="no" indent="yes" />
<xsl:template match="/">
<html>
<body bgcolor="#dddddd">
<!-- field[parentFieldSet='fstFields']/-->
<xsl:apply-templates select="fields/field"/>
</body>
</html>

</xsl:template>

<xsl:template match="field">
<xsl:choose>
<xsl:when test="./type='Text'">
<input type="text">
<xsl:attribute name="name">
<xsl:value-of select="name" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="id" />
</xsl:attribute>
<xsl:attribute name="FOR">
<xsl:value-of select="FOR" />
</xsl:attribute>
<xsl:attribute name="style">
<xsl:value-of select="style" />
</xsl:attribute>
<xsl:if test="./maxlength !=''">
<xsl:attribute name="maxlength">
<xsl:value-of select="maxlength" />
</xsl:attribute>
</xsl:if>
<xsl:if test="./size != ''">
<xsl:attribute name="size">
<xsl:value-of select="size" />
</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:when test="./type='fieldset'">
<fieldset>
<xsl:attribute name="name">
<xsl:value-of select="name" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="id" />
</xsl:attribute>
<xsl:attribute name="FOR">
<xsl:value-of select="FOR" />
</xsl:attribute>
<xsl:attribute name="style">
<xsl:value-of select="style" />
</xsl:attribute>
<xsl:if test="./maxlength !=''">
<xsl:attribute name="maxlength">
<xsl:value-of select="maxlength" />
</xsl:attribute>
</xsl:if>
<xsl:if test="./size != ''">
<xsl:attribute name="size">
<xsl:value-of select="size" />
</xsl:attribute>
</xsl:if>
<xsl:if test="./legend != ''">
<legend>
<xsl:value-of select="legend" />
</legend>
</xsl:if>
</fieldset>
</xsl:when>
<xsl:when test="./type = 'label'">
<label>
<xsl:attribute name="name">
<xsl:value-of select="name" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="id" />
</xsl:attribute>
<xsl:attribute name="FOR">
<xsl:value-of select="FOR" />
</xsl:attribute>
<xsl:attribute name="style">
<xsl:value-of select="style" />
</xsl:attribute>
<xsl:if test="./maxlength !=''">
<xsl:attribute name="maxlength">
<xsl:value-of select="maxlength" />
</xsl:attribute>
</xsl:if>
<xsl:if test="./size != ''">
<xsl:attribute name="size">
<xsl:value-of select="size" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="caption" />
</label>
</xsl:when>
<xsl:when test="./type='Checkbox'">
<input type="checkbox">
<xsl:attribute name="id">
<xsl:value-of select="id" />
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="name" />
</xsl:attribute>
<xsl:attribute name="style">
<xsl:value-of select="style" />
</xsl:attribute>
</input>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<<<< END XSL <<<

It outputs all the fields, but doesn't care which ones are supposed to
be inside the fielddset.

This is so that I can reuse my XSL/ASP with multiple form definition
templates built in XML...then I can realize the age old dream of
separating content from structure, and even processing code from
content
and structure...yay

I'd be grateful for any assistance or help or ideas

Philip
Jul 20 '05 #1
1 1867

"Philip" <pl**********@statestreet.com> wrote in message
news:21**************************@posting.google.c om...
Hi,

I am trying to output certain nodes inside another. I have an xml
template with field definitions for a form, and this includes
textfields, labels, checkboxes etc plus fieldssets. I defined them
like
this:

Hi,

Seems to me that what you need is :

<xsl:for-each select="fields">
<xsl:apply-templates select="field" />
</xsl:for-each>

...and this should replace the line that you currently have :

<xsl:apply-templates select="fields/field"/>

Regards,
Kenneth
Jul 20 '05 #2

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

Similar topics

3
by: Kevin | last post by:
I know this has probably been discussed many times before (I found answers when I searched yesterday), but I still can't get it to work... I have an attribute @OID that can contain any...
1
by: Rohit | last post by:
I have a XML which looks like this: <root> <row Site="ABC" ClassroomName="Calculus" StartDate="Jun 1 2004"/> <row Site="ABC" ClassroomName="Biology" StartDate="Jun 10 2004"/> <row Site="XYZ"...
2
by: Alex | last post by:
Subject: Looking for an XML (database-based) Query Reporting Tool/advice First off, let me apologize if this thread is somewhat off topic... PLEASE REPLY TO: xml@solex-bi.com I am looking...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
5
by: Mike_August | last post by:
Could someone help me out with the following? I've got 1)an xml file 2)an xsl 3)a schema My namespaces are as follow molecular_db.xml
4
by: MPA | last post by:
Hi, We are a small company with experience in client-server apps with PowerBuilder and most major databases. We have no internet experience. We are now looking into slimming our main application,...
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
3
by: gauravkg via DotNetMonster.com | last post by:
Hi i have a problem I have a product product_name=taj Mahal product_id=111 i and different users will be putting reviews title and review description. this is the following xml file i...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.