[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Processing directed acyclic graph (DAG) for object inh

Subject: Processing directed acyclic graph (DAG) for object inheritance in XSLT
From: Soumen Sarkar <SoumenS@xxxxxxxxx>
Date: Fri, 18 May 2001 20:39:56 -0700
directed acyclic graph
Dear XSLT experts,

Please refer to XML and XSLT files. I would like to process all <Attribute>
of a <Class>
by the following:

A. First get all attributes as defined in the class
B. Get all <Base> for a given <Class>, remove duplicates
C. Get attributes of <Base> class for all in step B.

Please take a look at XML file to know what I mean by <Class>, <Base>,
<Attribute>.

As you can see, I am trying to process in XSLT the directed acyclic graph
(DAG) for object inheritance
in my object model. I am able to do step A, B. I am failing to step C.
Please show me a way to do step C.
For example the <Class> TestClass should have <Attribute> from:

TestClass (self)
Base class Shelf
Base class Device
Base class MOBase
Base class ManagedElement
Base class Switch
Base class Card
Base class Slot

Thanks,
Soumen.

XML file
========
<?xml version='1.0'?>

<!--This file contains the Data definition to be used for AppDirector. -->

<DataRoot version = 'x.y.z'>

<ManagedObject>

<!--**************************** TestClass ****************************-->
  <Class name="TestClass" classid='99999' abstract='BooleanEnum.FALSE'>
  <Base name="Shelf"/>
  <Base name="Device"/>
  <Base name="Card"/>
  <Base name="Slot"/>
  </Class>

<!--**************************** MOBase ****************************-->
  <Class name='MOBase' classid='1' abstract='BooleanEnum.TRUE' >

  <Attribute name='name' type='DN' access='AccessEnum.RC'
attrlocation='AttrLocationEnum.NMS'/>
  <Attribute name='userLabel' type='String' default='Not Assigned'/>
  <Attribute name='uniqueID' type='Integer' access='AccessEnum.RC'/>
  <Attribute name='parentID' type='Integer'/>
  <Attribute name='parentType' type='Integer'/>
  </Class>

<!--**************************** ManagedElement
****************************-->
  <Class name='ManagedElement' classid='2' abstract='BooleanEnum.TRUE' >
  <Attribute name='location' type='String'/>
  <Attribute name='version' type='String'/>
  <Attribute name='managedElementType'  type='ManagedElementTypeEnum' />
  <Attribute name='communicationState'  type='CommunicationStateEnum'
default='CommunicationStateEnum.CS_AVAILABLE'/>
  <Attribute name='managedElementInfo' type='String' />
  </Class>

<!--**************************** Equipment ****************************-->
  <Class name='Equipment' classid='3' abstract='BooleanEnum.TRUE' >

  <Attribute name='nativeEMSName' type='String' />
  <Attribute name='equipmentObjectType' />
  <Attribute name='alarmMonitoringIndicator' type='Boolean' default='FALSE'
attrlocation='AttrLocationEnum.NMS'/>
  <Attribute name='serviceState'  type='ServiceStateEnum' access='RO' />
  <Attribute name='partNumber' type='String' access='AccessEnum.RO' />
  <Attribute name='version' type='String' access='AccessEnum.RO' />
  <Attribute name='serialNumber' type='String' access='AccessEnum.RO' />
  <Attribute name='equipmentInfo' type='String' access='AccessEnum.RO'/>
  </Class>

<!--**************************** EquipmentHolder
****************************-->
  <Class name='EquipmentHolder' classid='4' abstract='BooleanEnum.TRUE' >

  <Attribute name='nativeEMSName' type='String' access='AccessEnum.RW' />
  <Attribute name='holderType' type='String' access='AccessEnum.RO' />
  <Attribute name='installedEquipment' type='DN' access='AccessEnum.RW' />
  <Attribute name='acceptableEquipmentTypeList' type='Collection(String)'
access='AccessEnum.RO'/>
  <Attribute name='holderState' type='HolderStateEnum'
default='HolderStateEnum.EMPTY'/>
  </Class>

<!--**************************** SwitchHolder
****************************-->
  <Class name='Switch' classid='8' abstract='BooleanEnum.TRUE'
beangen='BooleanEnum.TRUE'>

  <Attribute name='switchA1' type='String' access='AccessEnum.RW' />
  <Attribute name='switchA2' type='String' access='AccessEnum.RW' />
  </Class>

<!--**************************** Network ****************************-->
  <Class name='Network' classid='5' abstract='BooleanEnum.FALSE'
beangen='BooleanEnum.TRUE'>
  <Base name='MOBase'/>
  </Class>

<!--**************************** Subnetwork ****************************-->
  <Class name='Subnetwork' classid='6' abstract='BooleanEnum.FALSE'
beangen='BooleanEnum.TRUE'>
  <Base name='MOBase'/>
  <Parent>Network</Parent>
  </Class>

<!--**************************** Device ****************************-->
  <Class name='Device' classid='7' abstract='BooleanEnum.FALSE'
beangen='BooleanEnum.TRUE'>
  <Base name='MOBase'/>
  <Base name='ManagedElement'/>
  <Base name='Switch'/>
  <ImplementBase name='Switch'
package='com.atoga.appdirector.server.managedobject.switch' />
  <Parent>Network</Parent>

  <Attribute name='deviceType'  type='DeviceTypeEnum' access='AccessEnum.RC'
/>
  <Attribute name='managementIpaddress' type='String' access='AccessEnum.RC'
/>
  <Attribute name='description' type='String' />
  <Attribute name='manufacturerName' default='Atoga Systems Inc.'/>
  <Attribute name='model' type='String' access='AccessEnum.RW'
attrlocation='AttrLocationEnum.NMS'/>
  <Attribute name='serialNumber' type='String' />
  <Attribute name='bandwidthCapacity' type='Integer' />
  <Attribute name='bandwidthAvailable' type='Integer'
attrlocation='AttrLocationEnum.BOTH' snmpoid='1.2.3.4.5.6'/>
  <Attribute name='minimumGuaranteedBwUnit' type='String' default='64Kbps'
attrlocation='AttrLocationEnum.BOTH'  snmpoid='1.2.3.4.5.6' persistencesize
= '48'/>
  <Attribute name='burstableGuaranteedBwUnit' type='String'
default='64Bytes' attrlocation='AttrLocationEnum.BOTH'
snmpoid='1.2.3.4.5.6'/>
  <Attribute name='maximumBurstSizeUnit' type='String' default='64Kbps'
attrlocation='AttrLocationEnum.BOTH' snmpoid='1.2.3.4.5.6'/>
  </Class>

</ManagedObject>

</DataRoot>

XSLT file
=========
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="DataRoot/ManagedObject/Class">
Managed object name is <xsl:value-of select="@name"/>
Attributes from this class are:
<xsl:for-each select="./Attribute">
Attribute: <xsl:value-of select="@name"/>
</xsl:for-each>
<!-- The variable TempBase will have all the Base Nodes for a given Class
(with the repeatativeness) -->
<xsl:variable name="TempBase">
<xsl:call-template name="findAllBaseClasses">
<xsl:with-param name="className" select="@name"/>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="$TempBase/Base">
<xsl:if test="not(./@name=preceding::node()/@name)">
Base class is <xsl:value-of select="@name"/>
Attributes from this class are:
<xsl:call-template name="findAttributes">
<xsl:with-param name="className" select="@name"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>

<xsl:template name="findAllBaseClasses">
<xsl:param name="className"/>
<xsl:for-each select="//Class[@name=$className]/Base">
Copying <xsl:value-of select="@name"/>
<xsl:copy-of select="."/>
<xsl:call-template name="findAllBaseClasses">
<xsl:with-param name="className" select="@name"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>

<xsl:template name="findAttributes">
<xsl:param name="className"/>
In findAttributes(<xsl:value-of select="$className"/>)
<xsl:for-each select="//Class[@name=$className]/Attribute">
<xsl:value-of select="@name"/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.