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.
- <Rules>
-
<MapRule input="@PARENT()" output="Sales_Totals" />
-
<MapRule input="''" output="Sales_Totals@name" />
-
<MapRule input="''" output="Sales_Totals@type" />
-
<MapRule input="" output="Sales_Totals@allTimeSales" />
-
<MapRule input="@PARENT()" output="ProductList" />
-
<MapRule input="" output="ProductList@year" />
-
<MapRule input="" output="ProductList@value" />
-
<MapRule input="@PARENT()" output="Product" /> ( Product node is getting created here)
-
<MapRule input="" output="Product@quarter" /> ("quarter" is an attribue of Product node)
-
<MapRule input="" output="Name" /> (PRoduct node has three leaf nodes - Name , Value, Sold)
-
<MapRule input="" output="Value" />
-
<MapRule input="" output="Sold" />
-
<MapRule input="@ENDPARENT()" output="Product" /> (Product node is getting closed here)
-
<MapRule input="" output="Services" />
-
<MapRule input="" output="Services@lawnservice" />
-
<MapRule input="@ENDPARENT()" output="ProductList"/>
-
<MapRule input="@ENDPARENT()" output="Sales_Totals"/>
-
</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.
Ex:
a) <MapRule input="@PARENT()" output="Sales_Totals" />
Here Sales_total is a node name (i.e, it is not a leaf node).
b) <MapRule input="''" output="Sales_Totals@name" />
Here "name" is an attribute of "Sales_Totals" 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(should be followed by @ symbol) in the below way.
- Sales_total
-
Sales_Total@name
-
Sales_Total@type
-
Sales_total@allTimeSales
-
Sales_TotalProductList (<- From here my problem area. )
-
Sales_TotalProductList@year
-
Sales_TotalProductList@value
-
Sales_TotalProductListProduct
-
Sales_TotalProductListProduct@Quarter
-
Sales_TotalProductListProductName
-
Sales_TotalProductListProductValue
-
Sales_TotalProductListProductSold
-
Sales_TotalProductListServices
-
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.
Thanks