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....
Solved! Go to Solution.
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>
Does putting this at the desired end of your line work?:
<br />
Here's the source:
Thanks for the feedback. But no go...
That worked for me. Not through Python, but just entering it manually in the Description. Thanks!!
either use the line separator
'\r\n'
(or) os.linesep can work in python
"\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...
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>
html tags did the trick!
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()