Note that there are some explanatory texts on larger screens.

plurals
  1. POHow transform xml element and sub elements attributes values into one new element and sub element
    primarykey
    data
    text
    <p>I have been looking for a good documentation to explain this without success. This my problem:</p> <p>this are my requirements</p> <ul> <li>root element must be change the name (this is done), </li> <li>Only one attribute name in second level element should element should be transformed in a newelement.</li> <li>Second level element and the rest of its attributes should be removed</li> <li>All the attributes in third level element (inside second level element) are transformed into a second level element.</li> <li>Third level element should be removed.</li> </ul> <p>Current</p> <pre><code>&lt;list&gt; &lt;type name="drum" acustic="true" pieces="5" &gt; &lt;part name="pearl" id="0" version="0" displayOrder="0" customizationLevel="basic" /&gt; &lt;part name="dw" id="1" version="0" displayOrder="0" customizationLevel="basic" /&gt; &lt;/type&gt; &lt;type name="guitar" acustic="true" pieces="1" &gt; &lt;part name="fender" id="0" version="0" displayOrder="0" customizationLevel="basic" /&gt; &lt;/type&gt; </code></pre> <p></p> <p>desired</p> <pre><code>&lt;instrumentList&gt; &lt;instrument&gt; &lt;instrumentType&gt;drum&lt;/instrumentType&gt; &lt;instrumentID&gt;0&lt;/instrumentID&gt; &lt;instrumentBrand&gt;pearl&lt;/instrumentBrand&gt; &lt;version&gt;0&lt;/version&gt; &lt;displayOrder&gt;0&lt;/displayOrder&gt; &lt;customizationLevel&gt;basic&lt;/customizationLevel&gt; &lt;/instrument&gt; &lt;intrument&gt; &lt;instrumentType&gt;drum&lt;/instrumentType&gt; &lt;instrumentID&gt;1&lt;/instrumentID&gt; &lt;instrumentBrand&gt;dw&lt;/instrumentBrand&gt; &lt;version&gt;0&lt;/version&gt; &lt;displayOrder&gt;0&lt;/displayOrder&gt; &lt;customizationLevel&gt;basic&lt;/customizationLevel&gt; &lt;/instrument&gt; &lt;instrument&gt; &lt;instrumentType&gt;guitar&lt;/instrumentType&gt; &lt;instrumentID&gt;0&lt;/instrumentID&gt; &lt;instrumentBrand&gt;fender&lt;/instrumentBrand&gt; &lt;version&gt;0&lt;/version&gt; &lt;displayOrder&gt;0&lt;/displayOrder&gt; &lt;customizationLevel&gt;basic&lt;/customizationLevel&gt; &lt;/instrument&gt; &lt;/instrumentList&gt; </code></pre> <p>So I have followed the following tutorial and threads without success <a href="https://stackoverflow.com/questions/4733880/convert-attribute-value-into-element">Thread 1</a> <a href="https://stackoverflow.com/questions/655411/converting-xml-elements-to-xml-attributes-using-xslt">Thread 2</a></p> <p>I can do part of it but not all. I'm sure there is something I'm not understanding here especially with the removing elements and creating new elements and using some of the attributes, not all of them. Even if someone could point me with a good reference where I can understand how the xslt parse the xml so I can have a better idea since all the examples I found they transform every single attribute or element and that unfortunately is not my case.</p> <p>Any help would be greatly appreciated</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload