Monday, 14 September 2015

XSLT Pointer

This is as much for my own future reference as for anyone else's help... but it's been a while since I'd done any XSLT. Since all the examples had the same incoming XML tags as the outgoing mapped structures, it was confusing as to what referred to incoming, and what referred to outgoing : 



The rule of thumb I'm following (pragmatic until the last!) is that if it's in quotes and has "ss:" in it, then that's from the source, and any "xml:element" content refers to the outgoing data.

Trying to access the "Attributes" in the source XML is simply a matter of using the "@" symbol.



So the above takes the following xml:

 <row r="2" x14ac:dyDescent="0.25" spans="1:5">
  <c r="A2" t="s"><v>5</v></c>
  <c r="B2" t="s"><v>6</v></c>
  <c r="C2" t="s"><v>7</v></c>
  <c r="D2" t="s"><v>8</v></c>
  <c r="E2" t="s"><v>9</v></c>
 </row>

and spits out xml tags without attributes... the "r" attributes have been chucked into "C1" tags:

<sheetData>
  <row>
    <c>
      <c1>A1</c1>
      <v>0</v>
    </c>
    <c>
      <c1>B1</c1>
      <v>1</v>
    </c>
    <c>




No comments:

Post a Comment