223
Views
11
Comments
Solved
[XML Records] add xml-tag with attribute and content
Question
xml-records
Service icon
Forge asset by Afonso Carvalho

Hey there!

When I use the "Attr_" and "Cont_" prefix for structure attributes, the output is like this:

i.e. with spaces.

How can I do it without spaces? Like this:

2019-06-15 21-39-22
Afonso Carvalho
 
MVP
Solution

Hello everyone,

I've uploaded a new version of the component as a stable release with the Indentation control option - I did not reuse the version available for testing as I had chosen to leave the option as False by default. 

However, this meant that the default component behaviour would change: previous versions would use indentation by default, and this one would not. Since this is an old component used in many software factories, I try to add new options without changing existing behaviours, no matter how "weird" they may be, in order to reduce the amount of effort for existing users. I've set the default for this option as True, which means that if you want to get rid of indentation, you'll need to explicitly set it to False.

My apologies for the mixup, and thank you for your assistance in resolving this.

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Hi absente,

Sorry it took so long to get to you on this, I've been having issues accessing the forums.

I'm not aware of any spaces being added depending on your tags. Are you certain these spaces aren't coming from your? Do you think you could share a sample module to help us reproduce the issue?

2024-04-26 09-08-41
Funs Vercoulen

Hello! 

We have the same issue, did you guys find a solution?

Best regards,

Funs Vercoulen

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Hello Funs,

I remember investigating this, but I could not reproduce the issue. If you've managed to make it happen consistently, do you think you could share a module with this behaviour? It looks like a bug, and I would be more than glad to correct it.

UserImage.jpg
Chris Lai

hi , i just facing the same issue, can anyone help to advise? 

-Attr_Type

-Cont_value

how can remove the space ? or any others way to create attribute with content?


<?xml version="0.1" encoding="UTF-8"?>

<DemoRecord>

<String Type="">

tttete

</String>

<Date></Date>

<Integer>0</Integer>

<Boolean>false</Boolean>

</DemoRecord>

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Hello Chris,

As I mentioned above, I am looking for a module to reproduce this behaviour. Do you think you could share an example module of this behaviour?

2018-11-06 15-50-22
Brandon Hop

Hi Afonso,

I encountered the same issue the last few days. Fixed it myself with just a simple Regex_Replace for the time being, but would be nice if we that step can be left out.

Created an OML with some examples but having some issues uploading it, getting an "unsupported file type" error :/ Is there another easy way I can provide you with the OML?

Edit: Okay that's strange, apparently the file was uploaded. The correct OML is attached.

XMLRecordsSpacing.oml
2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Thank you for the sample Brandon. I'll look into this and will let you know once I have results.

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Hello Brandon,

I took a look at the Extension code and by default, indentation is always used. I'm unsure as to why I was unable to reproduce the results earlier in the thread, it could be that the whitespace was already being removed elsewhere.

I've published a new version of the component  (1.6.11), but I've marked it as Under Development. You can use the new Indentation option in the DefaultConfig structure in order to control this behaviour and test it here.

This was a considerably more complicated change than what I was expecting from the way the indentation code was implemented. I do not think this will cause any issues with the syntax of the generated XML, but it is possible that some cases might not be indented correctly from now on. I've marked the new version as "Under Development" and would be very appreciative of any testing that you're willing to do. I'll keep it tagged like this for a couple of weeks until I make it available as a regular component version.

Thank you very much for your interest in the component.

2018-11-06 15-50-22
Brandon Hop

Hello Afonso,

Thanks for the effort you are putting in!

I will do a few tests in the coming days and will let you know.

2020-12-03 08-18-19
Pieter-Jan Hoedt

Hi Afonso,

Just had the issue and stumbled into this post. Thank you for the fix! 

Currently using this fix in production and seems to be working great.

Best Regards

Pieter-Jan

2019-06-15 21-39-22
Afonso Carvalho
 
MVP
Solution

Hello everyone,

I've uploaded a new version of the component as a stable release with the Indentation control option - I did not reuse the version available for testing as I had chosen to leave the option as False by default. 

However, this meant that the default component behaviour would change: previous versions would use indentation by default, and this one would not. Since this is an old component used in many software factories, I try to add new options without changing existing behaviours, no matter how "weird" they may be, in order to reduce the amount of effort for existing users. I've set the default for this option as True, which means that if you want to get rid of indentation, you'll need to explicitly set it to False.

My apologies for the mixup, and thank you for your assistance in resolving this.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.