473,734 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to add Parent node name(if any) to a child node XSLT 1.0

1 New Member
I will very helpful to you if you can help me out in my below problem. I am not getting idea what should be the right approach for this.
Here is my problem.

I have below (sample)xml.

Expand|Select|Wrap|Line Numbers
  1. <Rules>
  2. <MapRule input="@PARENT()" output="Sales_Totals" />
  3. <MapRule input="''" output="Sales_Totals@name" />
  4. <MapRule input="''" output="Sales_Totals@type" />
  5. <MapRule input="" output="Sales_Totals@allTimeSales" />
  6. <MapRule input="@PARENT()" output="ProductList" />
  7. <MapRule input="" output="ProductList@year" />
  8. <MapRule input="" output="ProductList@value" />
  9. <MapRule input="@PARENT()" output="Product" />  ( Product node is getting created here)
  10. <MapRule input="" output="Product@quarter" />    ("quarter" is an attribue of Product node)
  11. <MapRule input="" output="Name" />            (PRoduct node has three leaf nodes - Name , Value, Sold)    
  12. <MapRule input="" output="Value" />
  13. <MapRule input="" output="Sold" />
  14. <MapRule input="@ENDPARENT()" output="Product" /> (Product node is getting closed here)
  15. <MapRule input="" output="Services" />
  16. <MapRule input="" output="Services@lawnservice" />
  17. <MapRule input="@ENDPARENT()" output="ProductList"/>
  18. <MapRule input="@ENDPARENT()" output="Sales_Totals"/>
  19. </Rules>
In this xml , if the attribute "output" of the node "MapRule" contains "@" symbol then it is not a node name but an attribute of a node, otherwise node name.

a) <MapRule input="@PARENT( )" output="Sales_T otals" />
Here Sales_total is a node name (i.e, it is not a leaf node).

b) <MapRule input="''" output="Sales_T otals@name" />
Here "name" is an attribute of "Sales_Tota ls" node.

c)<MapRule input="" output="Name" />
Here attribute "input" is empty and attribute "output" does not have @ symbol , it means it is a leaf node.

I want to display the nodes and the attributes(shou ld be followed by @ symbol) in the below way.
Expand|Select|Wrap|Line Numbers
  1. Sales_total 
  2. Sales_Total@name
  3. Sales_Total@type
  4. Sales_total@allTimeSales
  5. Sales_TotalProductList (<- From here my problem area. )
  6. Sales_TotalProductList@year
  7. Sales_TotalProductList@value
  8. Sales_TotalProductListProduct
  9. Sales_TotalProductListProduct@Quarter
  10. Sales_TotalProductListProductName
  11. Sales_TotalProductListProductValue
  12. Sales_TotalProductListProductSold
  13. Sales_TotalProductListServices
  14. Sales_TotalProductListServices@lawnservice
I first thought of creating a variable and assigning the parent node to it. For ex var xyz = "Sales_node ". But this is not right because i cannot modify xyz with Sales_node/ProductList. And this is changing again and again. Appreciate if any one can help me in this.

Aug 27 '09 #1
1 3678
8,658 Recognized Expert Moderator Expert
to me it looks as if your XML is overcomplicatin g matters. after reading several times it looks as if it is a kind of XML definition.

point 1: to describe an XML file’s structure you should use XML Schema or a DTD (there are some more, but these are the most common)

point 2: if you don’t want to (or can’t) use those definition languages, at least structure your definition XML. this will make it easier to recognise parent-child-relations. this will also help applying XSLT/XPath.

Expand|Select|Wrap|Line Numbers
  1. <element name="Sales_Totals">
  2.   <attribute name="name"/>
  3.   <element name="ProductList">
  4.     <element name="Product"/>
  5.   </element>
  6. </element>
Note: a node in XML can be anything, a coarse grouping would be element node (that’s what I think you call “leaf node”), attribute node, text node & namespace node (there are around a dozen more node types)

PS. welcome @ Bytes.com
Sep 2 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: ahaideb | last post by:
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 | | 3 | 6 |
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML: **************************************************************
by: john smith | last post by:
Hello, I am having trouble getting the parent node of an xml document using xslt. I am trying to return the node wine, but this does not return wine but the element values under wine. I thouht this would work. I am looking for the prices context and then ask for the parent node right? What am I doing wrong? Thanks in advance for your help.
by: MrNobody | last post by:
Ok, so I'm absoultely positive this was working last night, but today I'm getting this error in my program when I try to add a child node to a parent node of a tree... The error says: Message: The action being performed on this control is being called from the wrong thread. You must marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action. Stack Trace: at...
by: Bill | last post by:
Hi I have a parent child forms. I want the close, maximize, and minimize buttons to be removed. One the child form I have set the maximize and minimize buttons to false. I have the child form mamiximze in the parent form. So then the maximized button is still active. But I want the child form to fill the parent form without the ability to close minimize or maximize the form like a default page.
by: MA | last post by:
Hi, How to access the total number of child nodes from a parent node. For example, I would like to get the total number of child nodes from <parent1and <parent2node. The SelectNodes method return the total number of <foldernodes (9) regardless of calling from the <parent1> and <parent2node. XML: ----------------------------------
by: Matteo Migliore | last post by:
Hi. I've a problem with parent-child circular references. Suppose have two classes, Person and Course: -------------------------- public class Person{ public Person(string name, Course course){ this.name = name; this.course = course;
by: nev | last post by:
I have placed fields on form using datadesigner. I have a parent, child and childchild table. When I navigate the parent, naturally the child and childchild follows. Due to certain requirements, I changed the bindings of the childchild fields to point to its true table. Of course, when I navigate the parent, the childchild fields will not follow anymore. Now I place this code in the childbindingsource currentchanged event to let the...
by: cookiejar | last post by:
We are using the following to retrieve parent child: Cursor get_child_org is SELECT distinct o.ORG_ORGANIZATION_ID org_id, o.name belongs_to, uic.code org_uic, SYS_CONNECT_BY_PATH(o.name, ' - ') "ORG_STRUCTURE"
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,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
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...
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...
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...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.