samedi 1 août 2015

xslt moving child attribute to parent

Input:

    <book>
     <chapter href="..">
      <topicref chunk="to-content" href"..">

      </topicref>
      <topicref chunk="to-content" href"..">

      </topicref>
     </chapter>
    </book>    

Output:

    <book>
     <chapter chunk="to-content" href="..">
      <topicref href"..">

      </topicref>
      <topicref href"..">

      </topicref>
     </chapter>
    </book> 

I cannot use xsl:attribute name="chunk">to-content</xsl:attribute> because it throws "creating an attribute here will fail if previous instructions create any children." warning and then error. I understand that as described here. Any workaround?

Using XSLT 2.0 with Saxon 9. (just getting the hang of XSLT/ S.O. still). Sorry if this is too broad but any help in any direction will be appreciated.

Aucun commentaire:

Enregistrer un commentaire