[xsd-users] start/end tags versus empty tag

Brad Howes howes at ll.mit.edu
Thu May 20 10:30:00 EDT 2010


On May 17, 2010, at 7:04 PM, Barrie Kovish wrote:

> I'm using XSD tree mapping.  I would like to be able to force empty elements to be written out as start end tags instead of an empty tag, i.e.
> start/end tags:
> 
> <car></car>
> 
> instead of empty tag:
> 
> <car/>
> 
> Is there a way to do this?  Just to answer the obvious question, why? We transform XML produced and consumed by a 3rd party application.  It
> turns out this application doesn't like <car/>.  


Seems like you could do a pattern match and substitution to achieve this:

    echo "<car/>" | sed -e "s@<\([^/]][^/]*\)/>@<\1></\1>@g"

gives

    <car></car>

I don't think there could be any false matches, but I'm not positive...

Brad

-- 
Brad Howes
Group 42
MIT Lincoln Laboratory • 244 Wood St. • Lexington, MA 02173
Phone: 781.981.5292 • Fax: 781.981.3495 • Secretary: 781.981.7420








More information about the xsd-users mailing list