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

1 Answer 1

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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.