---
schema_version: "1"
id: 248a14695b1af2fdbf68043cd990b2a7890fff8fff52d2d6202e231bc30ce1ac
title: Reference Multiple Inputs
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dataweave-cookbook-reference-multiple-inputs.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-reference-multiple-inputs
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 212e1336eba9df94ea8cda0cc6549f266f5b44846ff231a32c121f5cddce8aae
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
keywords: studio, anypoint, transform, transformer, format, xml, metadata, dataweave, data weave, datamapper, dwl, dfl, dw, output structure, input structure, map, mapping, remove, mapobject
---

# Reference Multiple Inputs

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

This DataWeave example takes three different input JSON files, one in the payload, another in a
variable and the third in an attribute. All of them are parts of the same Mule Event. The payload
contains an array of book objects, the variable has a set of currency exchange rates, and the
attribute specifies a year to be used as a query.

The example uses the following:

- `filter` to leave out the books that are older than the date specified in the incoming attribute.

- `map` to go through each book in the incoming array. Another `map` function then goes through the
  currencies in the variable to calculates the book’s price in each one. A third `map` function
  lists out all authors of a book in case there are more than one.

- `@` to define an XML attribute in the output.

DataWeave Script:

```dataweave
%dw 2.0
output application/xml
---
books: {
  (payload filter ($.properties.year > attributes.publishedAfter) map  (item)   ->  {
    book @(year: item.properties.year): {
      (vars.exchangeRate.USD map {
        price @(currency: $.currency): $.ratio * item.price
      }),
      title: item.properties.title,
      authors: { (item.properties.author map {
        author: $
      }) }
    }
  } )
}
```

Input JSON Payload:

```json
[
  {
    "type": "book",
    "price": 30,
    "properties": {
      "title": "Everyday Italian",
      "author": ["Giada De Laurentiis"],
      "year": 2005
    }
  },
  {
    "type": "book",
    "price": 29.99,
    "properties": {
      "title": "Harry Potter",
      "author": ["J K. Rowling"],
      "year": 2005
    }
  },
  {
    "type": "book",
    "price": 41.12,
    "properties": {
      "title": "Mule in Action",
      "author": ["David Dossot", "John D'Emic"],
      "year": 2009
    }
  },
  {
    "type": "book",
    "price": 49.99,
    "properties": {
      "title": "XQuery Kick Start",
      "author": [
        "James McGovern",
        "Per Bothner",
        "Kurt Cagle",
        "James Linn",
        "Kurt Cagle",
        "Vaidyanathan Nagarajan"
      ],
      "year": 2003
    }
  },
  {
    "type": "book",
    "price": 39.95,
    "properties": {
      "title": "Learning XML",
      "author": ["Erik T. Ray"],
      "year": 2003
    }
  }
]
```

Input Attributes:

```json
{
  "publishedAfter": 2004
}
```

Input Variable `exchangeRate`:

```json
{
  "USD": [
    { "currency": "EUR", "ratio": 0.92 },
    { "currency": "ARS", "ratio": 8.76 },
    { "currency": "GBP", "ratio": 0.66 }
  ]
}
```

Output XML:

```xml
<?xml version='1.0' encoding='US-ASCII'?>
<books>
  <book year="2005">
    <price currency="EUR">27.60</price>
    <price currency="ARS">262.80</price>
    <price currency="GBP">19.80</price>
    <title>Everyday Italian</title>
    <authors>
      <author>Giada De Laurentiis</author>
    </authors>
  </book>
  <book year="2005">
    <price currency="EUR">27.5908</price>
    <price currency="ARS">262.7124</price>
    <price currency="GBP">19.7934</price>
    <title>Harry Potter</title>
    <authors>
      <author>J K. Rowling</author>
    </authors>
  </book>
  <book year="2009">
    <price currency="EUR">37.8304</price>
    <price currency="ARS">360.2112</price>
    <price currency="GBP">27.1392</price>
    <title>Mule in Action</title>
    <authors>
      <author>David Dossot</author>
      <author>John D'Emic</author>
    </authors>
  </book>
</books>
```

## Related Examples

- [Extract Data](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-extract-data)

- [Merge Fields from Separate Objects](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-merge-multiple-payloads)

## See Also

- [DataWeave Types](https://docs.mulesoft.com/dataweave/2.3/dataweave-types)

- [DataWeave Selectors](https://docs.mulesoft.com/dataweave/2.3/dataweave-selectors)

- [DataWeave Cookbook](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook)
