New Line in metadata summary description

1478
7
Jump to solution
04-19-2018 12:26 PM
forestknutsen1
MVP Regular Contributor

is their and new way to add a new line into the metadata description and summary fields. I have a python batch job that is downloading external data into our system. As part of the process it is updating the metadata. I have been asked to append the summary with some of our organization's info. But I can not get it to honor the a new line when viewing the metadata in ArcCatalog. I have tried the classic "\n" in python. Looks fine in the raw xml but looks like some sort of white space stripping is going on when it is viewed in ArcCatalog. I also tried editing the metadata via ArcCatalog and I get the same effect....

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor

It must be being stripped by code, but can you confirm it behaves properly when done manually

(Pro being used in this example)

Here are the html tags being used with some extra gobbly stuff incase the first 4 lines mean anything to you

..... snip
<SCRIPT type=text/javascript xmlns="" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
xmlns:esri="http://www.esri.com/metadata/">
     /*  */
          function hideShow(divID) {
               var item = document.getElementById(divID);
               var itemShow = document.getElementById(divID + 'Show');
               var itemHide = document.getElementById(divID + 'Hide');
               if (item) {
                    if (item.className == 'hide') {
                         item.className='show';
                         itemShow.className='hide';
                         itemHide.className='show';
                    }
                    else {
                         item.className='hide';
                         itemShow.className='show';
                         itemHide.className='hide';
                    }
               }
          }
     /*  */
     </SCRIPT>
</HEAD>
<BODY oncontextmenu="return true" bgColor=#f7f8f8>
<DIV id=overview xmlns="" 
xmlns:esri="http://www.esri.com/metadata/"><!--StartFragment--><DIV>
<H3>Summary</H3>
<P id=summary></P><PRE class=wrap xmlns:msxsl="urn:schemas-microsoft-com:xslt">a summary
summary
<H3>Description</H3>
<P id=description></P><PRE class=wrap xmlns:msxsl="urn:schemas-microsoft-com:xslt"><DIV style="TEXT-ALIGN: left"><DIV><P><SPAN>line1</SPAN></P><P><SPAN>line2</SPAN></P><P><SPAN>line 3</SPAN></P><P><SPAN></P></DIV></DIV></SPAN></PRE></DIV><!--EndFragment--></DIV></BODY></HTML>

View solution in original post

7 Replies
MicahBabinski
Regular Contributor

Does putting this at the desired end of your line work?:

<br /> 

Here's the source:

Adding a new line/break tag in XML - Stack Overflow 

0 Kudos
forestknutsen1
MVP Regular Contributor

Thanks for the feedback. But no go...

0 Kudos
BalajiVeera
Occasional Contributor

either use the line separator

'\r\n'

(or) os.linesep can work in python

forestknutsen1
MVP Regular Contributor

"\r\n" also get the same result. The fact that it shows up okay in editor and raw xml exports makes me think that arc is doing white space stripping in the description view... it would be nice if someone from esri could confirm this is the desired behavior...

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

It must be being stripped by code, but can you confirm it behaves properly when done manually

(Pro being used in this example)

Here are the html tags being used with some extra gobbly stuff incase the first 4 lines mean anything to you

..... snip
<SCRIPT type=text/javascript xmlns="" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
xmlns:esri="http://www.esri.com/metadata/">
     /*  */
          function hideShow(divID) {
               var item = document.getElementById(divID);
               var itemShow = document.getElementById(divID + 'Show');
               var itemHide = document.getElementById(divID + 'Hide');
               if (item) {
                    if (item.className == 'hide') {
                         item.className='show';
                         itemShow.className='hide';
                         itemHide.className='show';
                    }
                    else {
                         item.className='hide';
                         itemShow.className='show';
                         itemHide.className='hide';
                    }
               }
          }
     /*  */
     </SCRIPT>
</HEAD>
<BODY oncontextmenu="return true" bgColor=#f7f8f8>
<DIV id=overview xmlns="" 
xmlns:esri="http://www.esri.com/metadata/"><!--StartFragment--><DIV>
<H3>Summary</H3>
<P id=summary></P><PRE class=wrap xmlns:msxsl="urn:schemas-microsoft-com:xslt">a summary
summary
<H3>Description</H3>
<P id=description></P><PRE class=wrap xmlns:msxsl="urn:schemas-microsoft-com:xslt"><DIV style="TEXT-ALIGN: left"><DIV><P><SPAN>line1</SPAN></P><P><SPAN>line2</SPAN></P><P><SPAN>line 3</SPAN></P><P><SPAN></P></DIV></DIV></SPAN></PRE></DIV><!--EndFragment--></DIV></BODY></HTML>
forestknutsen1
MVP Regular Contributor

html tags did the trick!

0 Kudos
David_Wilton
New Contributor II

For ArcGIS Pro 2.7 I found the following to work fine in python:

from arcpy import metadata as md

new_md = md.Metadata()
new_md.description = 'this is a <br>test'

tgt_item_md = md.Metadata(fc)
if not tgt_item_md.isReadOnly:
    tgt_item_md.copy(new_md)
    tgt_item_md.save()

 

0 Kudos