SamiBOB
SamiBOB

Reputation: 243

get value of child from parent

From parent node, i need to test the value of one of the child's in order to generate the adequate output.

my XML file looks :

 <Tables>
    <Table>
      <Multi_entity>SPECIFIC</Multi_entity>
      <Table_name>CATEG</Table_name>
      <Is_temporary>FALSE</Is_temporary>
      <Tablespace>APSYS_LOCATION_1</Tablespace>
      <Column>
        <Column_name>CATEGI</Column_name>
        <Position>1</Position>
        <Type>Small</Type>
        <Size>22</Size>
        <Null>No</Null>
        <Default>Yes</Default>
        <Attribute>Precision=5</Attribute>
        <Attribute>Scale=0</Attribute>
      </Column>
      <Column>
        <Column_name>CATEGC</Column_name>
        <Position>2</Position>
        <Type>LongVarchar</Type>
        <Size>1</Size>
        <Null>No</Null>
        <Default>Yes</Default>
        <Attribute>Precision=0</Attribute>
        <Attribute>Scale=0</Attribute>
      </Column>
      <Column>
        <Column_name>CATEG_NAME</Column_name>
        <Position>3</Position>
        <Type>Varchar</Type>
        <Size>23</Size>
        <Null>No</Null>
        <Default>Yes</Default>
        <Attribute>Precision=0</Attribute>
        <Attribute>Scale=0</Attribute>
      </Column>
      <Column>
        <Column_name>CATEG_TYPE</Column_name>
        <Position>4</Position>
        <Type>Small</Type>
        <Size>22</Size>
        <Null>No</Null>
        <Default>Yes</Default>
        <Attribute>Precision=5</Attribute>
        <Attribute>Scale=0</Attribute>
      </Column>
    </Table>

from the "Table" node, i need to know if one of the "Column" has a "Type" value "LongVarchar".

Upvotes: 1

Views: 127

Answers (2)

SamiBOB
SamiBOB

Reputation: 243

I managed to come along my problem in a way that is so easy that i am really astonished about it's simplicity :

<xsl:when test="Column/Type='LongVarchar'">

that's it and it works perfectly. Thanks folks for all your Help.

Upvotes: 1

Martin Honnen
Martin Honnen

Reputation: 167716

Does

<xsl:template match="Table[Column/Type = 'LongVarchar']">
  <!-- now transform or output as neeed -->
</xsl:template>

help? That matches any Table having a Column with Type being that value LongVarchar.

Upvotes: 3

Related Questions