0

How correctly add an "upper-case" expression in already working XSLT code?

sample:

  <xsl:template match="Document">
    <Document  ABC="{element1/@attr1}{element2/@attr2}"
               DEF="{normalize-space(concat(element1/@attr-3, element1/element2/@attr4, ' ',element1/element2/@attr5, ' '))}"
               GHI="{element3/@attr6}">
      <xsl:copy-of select="@*" />
      <xsl:apply-templates/>
    </Document>
  </xsl:template>

need to up ABC, DEF, GHI' s values

Or, its better (or equal) to make this upper-case by the separate template? interesting in both possibilities

Alex
  • 49
  • 1
  • 5
  • Not sure what exactly your question is. I would probably use some variables for code readability, but just adding translate() on top of what you have would work too. Seems like you're asking for opinions, which is off-topic. – michael.hor257k Dec 01 '19 at 01:35

1 Answers1

1

In XSLT 2.0 or more you can simply use the upper-case() method.

Example:

ABC="{upper-case(element1/@attr1)}{upper-case(element2/@attr2)}"

Or in XSLT 1.0, refer to this answer: How can I convert a string to upper- or lower-case with XSLT?

Sebastien
  • 2,672
  • 1
  • 8
  • 13