2

I have a XML and need to convert this into another XML using XSL. I'm quite new to XSL and need help. I'm using Oracle JDeveloper to build the XSL.

I need to provide a XML output that looks like:

<NumericField id="456">1</NumericField>    

where 456 and 1 come from variable that will be defined using

 <xsl:value-of select="/XYZ/ASDF"/>

I tried this using many ways but always end up with errors or undesired output. Can you help how my XSL should look like.

Currently this is how my XSL looks like which is incorrect:

<NumericField id= "<xsl:value-of select="/XYZ/ASDF"/>" > 
<xsl:value-of select="/XYZ/DSAF"/> 
</NumericField>
3
  • 1
    Use either xsl:attribute or an attribute value template. Commented Oct 29, 2019 at 11:06
  • P.S. If they both come from the same variable, then how can one be 456 and the other 1?? Commented Oct 29, 2019 at 11:15
  • They are not the same variable (ASDF vs DSAF), hard to see ;) Commented Oct 29, 2019 at 12:49

2 Answers 2

2

Here is the code

<xsl:element name="NumericField">
    <xsl:attribute name="id">
        <xsl:value-of select="/XYZ/ASDF"/>
    </xsl:attribute>
    <xsl:value-of select="/XYZ/DSAF"/>
</xsl:element>
Sign up to request clarification or add additional context in comments.

Comments

0

Example of AVT (attribute value template) mentioned in the comments...

<NumericField id="{/XYZ/ASDF}"> 
  <xsl:value-of select="/XYZ/DSAF"/> 
</NumericField>

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.