[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to retain the end tag when outputting an empty

Subject: Re: How to retain the end tag when outputting an empty element?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Jun 2022 21:10:24 -0000
Re:  How to retain the end tag when outputting an empty
> Using this (admittedly simplified) theory of XML processing, though, the
answer to bhow to get <duck></duck> instead of <duck/>b is
> $ perl -pe 's,<([A-Za-z][A-Za-z0-9._-]+)/>,<$1></$1>,g;' < INPUT.xml >
OUTPUT.xml
> or similar.
>


And, like all attempts to process XML using regular expressions, it is of
course wrong.

- It won't match an empty element tag that contains whitespace or attributes

- It will match things that aren't empty element tags, because they occur in
comments or CDATA.

So if you have a document with a comment that says:

<!-- The code below changes <x/> to <x></x> -->

then be prepared for your comments to be garbled.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.