File: 159.coffee

package info (click to toggle)
node-xml2js 0.6.2%2B~cs15.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,312 kB
  • sloc: xml: 119; javascript: 7; makefile: 2
file content (125 lines) | stat: -rw-r--r-- 4,349 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
suite 'Tests specific to issues:', ->
  test 'multiple elements with different values. Issue 159', ->
    obj = {
      'mdui:UIInfo': {
        "mdui:DisplayName": [
          { "@xml:lang": "de", "#text": "AAA" }
          { "@xml:lang": "en", "#text": "BBB" }
        ]
      }
    }

    eq(
      xml(obj, { headless: true }).end()

      '<mdui:UIInfo>' +
        '<mdui:DisplayName xml:lang="de">AAA</mdui:DisplayName>' +
        '<mdui:DisplayName xml:lang="en">BBB</mdui:DisplayName>' +
      '</mdui:UIInfo>'
    )


  test 'nested array. Issue 159', ->
    obj = {
        "category": {
            "@category-id": "twe-root",
            "display-name": {
                "#text": "Root",
                "@xml:lang": "x-default"
            },
            "description": {
                "#text": "Master Catalogue for Treasury Wines",
                "@xml:lang": "x-default"
            },
            "online-flag": {
                "#text": true
            },
            "attribute-groups": [{
                "attribute-group": {
                    "@group-id": "wine",
                    "display-name": {
                        "#text": "Wine Attributes",
                        "@xml:lang": "x-default"
                    },
                    "attribute": [{
                        "@attribute-id": "wineContentChannels",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineTastingNotesPDF",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineCOGS",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineCollection",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineType",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineVariety",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineBottleType",
                        "@system": false
                    },
                    {
                        "@attribute-id": "wineVintage",
                        "@system": false
                    }
                    ]
                }
            },
            {
                "attribute-group": {
                    "@group-id": "coreProduct",
                    "display-name": {
                        "#text": "Core Product Attributes",
                        "@xml:lang": "x-default"
                    },
                    "attribute": [{
                        "@attribute-id": "csrOnly",
                        "@system": false
                    }]
                }
            }
            ]
        }
    }
    
    eq(
      xml(obj, { headless: true }).end({ pretty: true })

      """
      <category category-id="twe-root">
        <display-name xml:lang="x-default">Root</display-name>
        <description xml:lang="x-default">Master Catalogue for Treasury Wines</description>
        <online-flag>true</online-flag>
        <attribute-groups>
          <attribute-group group-id="wine">
            <display-name xml:lang="x-default">Wine Attributes</display-name>
            <attribute attribute-id="wineContentChannels" system="false"/>
            <attribute attribute-id="wineTastingNotesPDF" system="false"/>
            <attribute attribute-id="wineCOGS" system="false"/>
            <attribute attribute-id="wineCollection" system="false"/>
            <attribute attribute-id="wineType" system="false"/>
            <attribute attribute-id="wineVariety" system="false"/>
            <attribute attribute-id="wineBottleType" system="false"/>
            <attribute attribute-id="wineVintage" system="false"/>
          </attribute-group>
        </attribute-groups>
        <attribute-groups>
          <attribute-group group-id="coreProduct">
            <display-name xml:lang="x-default">Core Product Attributes</display-name>
            <attribute attribute-id="csrOnly" system="false"/>
          </attribute-group>
        </attribute-groups>
      </category>
      """
    )