3

how can We sort the below output using xmllint c14n option.

I have tried below options but i don't see any sorting happening here. I'm expecting all elements and child elements to be sorted.

xmllint c14n

xmllint --exc-c14n

    <class-of-service>
            <rewrite-rules>
                <exp>
                    <name>BEST-EFFORT</name>
                    <forwarding-class>
                        <name>DATA</name>
                        <loss-priority>
                            <name>low</name>
                            <code-point>BEST-EFFORT</code-point>
                        </loss-priority>
                        <loss-priority>
                            <name>high</name>
                            <code-point>BEST-EFFORT</code-point>
                        </loss-priority>
                    </forwarding-class>
                </exp>
            </rewrite-rules>
            <code-point-aliases>
                <exp>
                    <name>BEST-EFFORT</name>
                    <bits>000</bits>
                </exp>
                <exp>
                    <name>EXP1</name>
                    <bits>001</bits>
                </exp>
            </code-point-aliases>
            <forwarding-classes>
                <class>
                    <name>DATA</name>
                    <queue-num>0</queue-num>
                </class>
                <class>
                    <name>REAL-TIME</name>
                    <queue-num>1</queue-num>
                </class>
            </forwarding-classes>
        </class-of-service>
Babu K T
  • 41
  • 4
  • Order of elements can be significant. Only attributes can be sorted without changing the semantics of the document. – choroba Apr 22 '17 at 19:38
  • Is that we can't sort the xml unless we have attributes ? – Babu K T Apr 24 '17 at 03:02
  • 1
    @choroba I want to compare similar output which in different order and make sure both . Is that we can't sort the xml tree unless we have attributes ? – Babu K T Apr 24 '17 at 03:08
  • You can do whatever you like, but you'll need more than just an option to xmllint. – choroba Apr 24 '17 at 05:11
  • 1
    I'm giving like xmllint c14n data.xml > data_can.xml. Similarly I have one more file with same output but elements in different oder. I dont see any sorting with files. Data in "data.xml" is same as "data_can.xml" – Babu K T Apr 24 '17 at 14:20
  • Yes, you need to write a program to sort the elements. – choroba Apr 24 '17 at 14:26

0 Answers0