2

I'm trying to transform one XML document (REQ-IF) into another XML document (UML-Class-Diagram document) using XSLT.

My Problem now is the following:

REQ-IF provides datatypes as:

<Datatypes>
<DATATYPE-DEFINITION-STRING IDENTIFIER="xyz" LONG-NAME="ABC"
</Datatypes>

and Objects as:

<SPEC-OBJECTS>
<VALUES>
<ATTRIBUTE-VALUE-STRING THE-VALUE="some-value">
          <DEFINITION>
            <ATTRIBUTE-DEFINITION-STRING-REF>xyz</ATTRIBUTE-DEFINITION-STRING-REF>
          </DEFINITION>
</ATTRIBUTE-VALUE-STRING>
</VALUES
<SPEC-OBJECTS>

This is resembled in my UML representation as:

<ownedAttribute xmi:id="some-ID" name="ABC" type="some-ID">

please note the ABC and xyz.

I therefore use <xsl:for-each> to loop through the Objects and another <xsl:for-each> to loop through the values. Now I have to take the Datatype-ID from the value, find out which Datatype it is and write the Datatype-name into the output file. How do I do that?

Thank you so much in advance

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
user2509422
  • 125
  • 10

1 Answers1

0

Try /Datatypes[DATATYPE-DEFINITION-STRING/@IDENTIFIER = current()/ATTRIBUTE-VALUE-STRING/DEFINITION/ATTRIBUTE-DEFINITION-STRING-REF]/DATATYPE-DEFINITION-STRING/@LONG-NAME.

I admit I didn't actually test this, but you'll probably get the idea. The point of current is to access the XSLT context (the VALUES element) as opposed to the current XPath context that is active in the filter.

Dabbler
  • 9,733
  • 5
  • 41
  • 64