# Get unsanitized access to tags in the tool xml

**URL:** <https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363>\
**Category:** Uncategorized\
**Tags:** dataset, development-tools, tags\
**Created:** [May 23, 2019, 8:01am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363 "2019-05-23T08:01:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![scholtalbers](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@scholtalbers](https://help.galaxyproject.org/u/scholtalbers)\
**Post date:** [May 23, 2019, 8:01am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/1 "2019-05-23T08:01:58Z")

</div>

I’m currently using the following [line](https://github.com/scholtalbers/galaxy-dataset-exporter/blob/master/dataset-exporter.xml#L17) to get tags of datasets to the underlying tool:

```
#set tags = ','.join(str(t.value) for t in $dataset.tags)

```

This however this does not return the original tags, they get truncated (losing `#` and the `name:`), converted to lowercase and special characters are removed. Is there a better way to get access to tags in the tool xml?

---

<div class="post-metadata">

**Author:** ![mvdbeek](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/mvdbeek/32/110_2.png) [@mvdbeek](https://help.galaxyproject.org/u/mvdbeek)\
**Post date:** [May 23, 2019, 11:15am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/2 "2019-05-23T11:15:10Z")

</div>

You need to get `t.name` and `t.value`. `.name` is the first part before the `:`

---

<div class="post-metadata">

**Author:** ![scholtalbers](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@scholtalbers](https://help.galaxyproject.org/u/scholtalbers)\
**Post date:** [May 23, 2019, 2:19pm UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/3 "2019-05-23T14:19:38Z")

</div>

Thanks @mvdbeek, can the tool also get access to unsanitized or at least preserved casing of tag values? e.g. `#hello:YoU` vs `#hello:you`

---

<div class="post-metadata">

**Author:** ![mvdbeek](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/mvdbeek/32/110_2.png) [@mvdbeek](https://help.galaxyproject.org/u/mvdbeek)\
**Post date:** [May 24, 2019, 8:55am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/4 "2019-05-24T08:55:30Z")

</div>

There’s no sanitization anywhere, but tags are linked via lowercase, so maybe you’d need to use  
`user_tname` and `user_value`

---

<div class="post-metadata">

**Author:** ![scholtalbers](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@scholtalbers](https://help.galaxyproject.org/u/scholtalbers)\
**Post date:** [May 24, 2019, 2:59pm UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/5 "2019-05-24T14:59:31Z")

</div>

Thanks @mvdbeek that works, although not that easy(or I might also just be doing something wrong) and I guess the cheetah templating is then still sanitizing characters like `$` ?  
Anyway the following snippet works for me to get both the `named:tags` and `simpletags`:

```auto
#for $t in $dataset.tags:
    #if $t.user_tname == 'name':
        #set taglist = taglist + [t.user_value]
    #else:
        #set taglist = taglist + [t.user_tname]
    #end if
#end for
```

---

<div class="post-metadata">

**Author:** ![mvdbeek](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/mvdbeek/32/110_2.png) [@mvdbeek](https://help.galaxyproject.org/u/mvdbeek)\
**Post date:** [May 31, 2019, 9:13am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/6 "2019-05-31T09:13:19Z")

</div>

The way you’re looping you don’t maintain the tags as they are stored in Galaxy.  
I think the correct way would be

`#set tags = ','.join(["%s:%s" % (t.user_tname, t.user_value) if t.user_tname else str(t.user_value) for t in $dataset.tags])`

---

<div class="post-metadata">

**Author:** ![mvdbeek](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/mvdbeek/32/110_2.png) [@mvdbeek](https://help.galaxyproject.org/u/mvdbeek)\
**Post date:** [May 31, 2019, 9:15am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/7 "2019-05-31T09:15:55Z")

</div>

And we could also make that the ` __str__ ` method of the `ItemTagAssociation` class so that you only have to do `$set tags = ",".join($dataset.tags)`

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [March 17, 2026, 6:51am UTC](https://help.galaxyproject.org/t/get-unsanitized-access-to-tags-in-the-tool-xml/1363/8 "2026-03-17T06:51:30Z")

</div>


