xslt: combine element attributes based on the value of another element's attribute
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 1
- Joined: Thu Aug 12, 2021 9:03 am
xslt: combine element attributes based on the value of another element's attribute
Post by summer_seth »
Is there a way to merge or combine row element based on the tables id and name?
Input:
<?xml version='1.0' encoding='UTF-8'?>
<ns1:Book xmlns:ns1="" id="3430">
<ns1:types>
<ns1:tables id="3431" name="001">
<ns1:table>
<ns1:row row1="A" />
<ns1:row row2="001" />
<ns1:row row3="111" />
</ns1:table>
</ns1:tables>
<ns1:tables id="3431" name="001">
<ns1:table>
<ns1:row row1="A" />
<ns1:row row2="002" />
<ns1:row row3="222" />
</ns1:table>
</ns1:tables>
<ns1:tables id="3435" name="002">
<ns1:table>
<ns1:row row1="A" />
<ns1:row row2="001" />
<ns1:row row3="111" />
<ns1:row row4="033793" />
<ns1:row row5="08122021" />
</ns1:table>
</ns1:tables>
</ns1:tabless>
</ns1:Book>
Aside from combining, have each row set in 1 line.
Output:
<?xml version='1.0' encoding='UTF-8'?>
<ns1:Book xmlns:ns1="" id="3430">
<ns1:types>
<ns1:tables id="3431" name="001">
<ns1:table>
<ns1:row row1="A" row2="001" row3="111" />
<ns1:row row1="A" row2="002" row3="222" />
</ns1:table>
</ns1:tables>
<ns1:tables id="3435" name="002">
<ns1:table>
<ns1:row row1="A" row2="001" row3="111" row4="033793" row5="08122021" />
</ns1:table>
</ns1:tables>
</ns1:tabless>
</ns1:Book>
Input:
<?xml version='1.0' encoding='UTF-8'?>
<ns1:Book xmlns:ns1="" id="3430">
<ns1:types>
<ns1:tables id="3431" name="001">
<ns1:table>
<ns1:row row1="A" />
<ns1:row row2="001" />
<ns1:row row3="111" />
</ns1:table>
</ns1:tables>
<ns1:tables id="3431" name="001">
<ns1:table>
<ns1:row row1="A" />
<ns1:row row2="002" />
<ns1:row row3="222" />
</ns1:table>
</ns1:tables>
<ns1:tables id="3435" name="002">
<ns1:table>
<ns1:row row1="A" />
<ns1:row row2="001" />
<ns1:row row3="111" />
<ns1:row row4="033793" />
<ns1:row row5="08122021" />
</ns1:table>
</ns1:tables>
</ns1:tabless>
</ns1:Book>
Aside from combining, have each row set in 1 line.
Output:
<?xml version='1.0' encoding='UTF-8'?>
<ns1:Book xmlns:ns1="" id="3430">
<ns1:types>
<ns1:tables id="3431" name="001">
<ns1:table>
<ns1:row row1="A" row2="001" row3="111" />
<ns1:row row1="A" row2="002" row3="222" />
</ns1:table>
</ns1:tables>
<ns1:tables id="3435" name="002">
<ns1:table>
<ns1:row row1="A" row2="001" row3="111" row4="033793" row5="08122021" />
</ns1:table>
</ns1:tables>
</ns1:tabless>
</ns1:Book>
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service