473,802 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Level information for XML

HI Gurus,

I have xml file in this format

<hierarchy>
<entity>
<contents>
<entity>
</entity>
</contents>
</entity>
<entity>
<contents>
<entity>
</entity>
</contents>
</entity>
</hierarchy>

I want to have attribute level for all <entity> node
like

<entity level=1>
<contents>
<entity level=2>
</entity>
</contents>
</entity>
<entity level=1>
<contents>
<entity level=2>
</entity>
</contents>
</entity>

Can someone help to get this using xslt.

thanks
gbk

Jul 20 '05 #1
1 1484
> HI Gurus,

I have xml file in this format

<hierarchy>
<entity>
<contents>
<entity>
</entity>
</contents>
</entity>
<entity>
<contents>
<entity>
</entity>
</contents>
</entity>
</hierarchy>

I want to have attribute level for all <entity> node

Can someone help to get this using xslt.

Coming right up:-)

<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output indent="yes" method="xml"/>

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

<xsl:template match="entity">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribut e name="level"><x sl:value-of select="count(a ncestor::entity ) +1 "/></xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="contents ">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

P.S. remember that attributes have to be qouted at all times in XML.

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #2

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

Similar topics

2
5651
by: robert | last post by:
well, talk about timely. i'm tasked to implement a security feature, and would rather do so in the database than the application code. the application is generally Oracle, but sometimes DB2. Oracle has what it calls package DBMS_RLS, which implements application ignorant row level security. scanning this group yielded "you can't do that; use views". then i dug out DB2Mag qtr 1 2004, and there is MLS for v8/390. from this article,...
9
2915
by: yu_sha | last post by:
Hello everyone We have a bunch of components registered under COM+ with 'transaction required' option. On the client we are using iSeries Access 5.2.0, with all possible fixes applied (Service level SI16136, iSeries ODBC driver version 9.00.09.00). Server is DB2/AS400 05.02.0001 (that's what ODBC driver reports. So, I
3
2511
by: Ais | last post by:
Hi.. Presently i'm trying to install IBM Db2 Software on my Windows XP Operating systems. I'm using IBM(R) DB2(R) Universal Database Enterprise Server Edition, Version 8.1. After installation of the Above , i installed DB2 service Pack FP5_WR21334_ESE.
4
3337
by: Mike MacSween | last post by:
It's a form, with (so far) 4 tab pages on it, each of which holds 2/3/4 subforms. (I like tabbed forms by the way - do we all?) Basically the subforms are different ways of looking at the data. It's the orchestral management thing still. So tab 1 looks at each musician, the events they're booked onto, which jobs they're doing etc.
3
8670
by: Eric Porter | last post by:
Dear All, I have a VB6.COM program using a VB6.COM DLL, which in turn uses ADODB that performs various bits of SQL. I have re-written the VB6.COM DLL in C#.NET (with a VB6 shell), which uses the ADODB.Interop library supplied with .NET. The VB6.COM program above calls this C#.NET library in an effort to perform the equivalent functionality.
1
24056
by: riceboy_inc | last post by:
Hello; First time posting and hoping to get some help! I have been going to school for Computer Science for 2+ years now, and am finally getting into some serious courses. I recently had to work on a lab where I had to complete 17 algorithms in bit-level C code. After a few hours (8+) I was able to put together a code for each of the 17 puzzles. The reason this assignment was so hard is because of the restrictions on it. Now I completed the...
1
2670
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to access insert, update delete and select. Let me explain clearly For example think we are using asp/asp.net website
7
17254
by: pamela fluente | last post by:
I have been using something like: public void SaveJPG(Image Image, string FileName, long QualityLevel_0_100, long ColorDepthLevel) { ImageCodecInfo ImageCodecInfoJPG = GetEncoderInfo("image/jpeg"); EncoderParameters EP = new EncoderParameters(2); EP.Param(0) = new EncoderParameter(Encoder.Quality, QualityLevel_0_100); EP.Param(1) = new EncoderParameter(Encoder.ColorDepth,
6
1452
by: python | last post by:
I need to generate multi-level incrementing labels for an outline/hierarchy where the string for each level of a label is based on an incrementing sequence like 1, 2, 3 or A, B, C, or even I, II, III. For simplicity, assume that each level's label segment is separated by a period ("."). I will pass an integer level (1 ... N) to this function/object so that level specific counters get reset when the level changes. I will use this...
7
2448
by: db2admin | last post by:
hello, where can i see what optimization level a certain sql has used ? is there any snapshot, event monitor, query patroller information which can be used to see that ? regards, db2admin
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10536
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.