Skip Menu |
 

This queue is for tickets about the XML-Twig CPAN distribution.

Report information
The Basics
Id: 24954
Status: resolved
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: sjurnm [...] mac.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in:
  • 3.30
  • 3.31
  • 3.32



Subject: Feature Request with patch: cvs-friendly pretty-print option
Date: Wed, 14 Feb 2007 23:21:38 +0200
To: bug-XML-Twig [...] rt.cpan.org
From: Sjur Moshagen <sjurnm [...] mac.com>
Download (untitled) / with headers
text/plain 3.3k
Hello, Twig produces a number of useful output formats, but not exactly what is needed to adhere to the guidelines outlined at http:// www.oracle.com/webapps/online-help/jdeveloper/10.1.3/state/content/ navId.4/navSetId._/vtTopicFile.teamworking%7Cscs% 7Cscs_u_writingversioncontrollablexml~html/ - Writing Version Controllable XML. Specifically, the following combination of options isn't available in my version (which is not the completely newest, but according to the changelog, this feature has not yet been added): * attributes, in sorted order, on separate lines from their element * indented output (easier human readability) * wrapped lines All of them are available in one or more of the existing pp formats, but not all three combined. The attached patch adds a new pp option indented_a (_a as in attribute), with alias cvs, which provides this output style. The rationale behind this output style is to reduce the number of irrelevant diffs when xml documents are stored in a version control system like CVS. As with most other output styles, this one is NOT guaranteed to keep the document valid according to the DTD. Use at your own risk:-) The patched version was tested on a small XML document, and seemed to perform as expected, but should probably be tested on larger documents before the change is commited. The patch is made against the following version: # $Id: Twig_pm.slow,v 1.303 2006/05/26 08:07:14 mrodrigu Exp $ It was made and tested on the following system: Mac OS X 10.4.8 This is perl, v5.8.6 built for darwin-thread-multi-2level (with 3 registered patches, see perl -V for more detail) As I don't know how the bug tracker handles e-mail attachements, I also paste in the patch at the end of this e-mail (it is short). Best regards, Sjur 6842c6842 < my ($NSGMLS, $NICE, $INDENTED, $INDENTEDC, $WRAPPED, $RECORD1, $RECORD2)= (1..7); --- Show quoted text
> my ($NSGMLS, $NICE, $INDENTED, $INDENTEDA, $INDENTEDC, $WRAPPED,
$RECORD1, $RECORD2)= (1..8); 6850a6851,6855 Show quoted text
> indented_a => $INDENTEDA, # nice, indented, and with
attributes on separate Show quoted text
> # lines as the nsgmls style, as
well as wrapped Show quoted text
> # lines - to make the xml friendly
against line- Show quoted text
> # oriented diffs > cvs => $INDENTEDA, # alias for indented_a
6950c6955 < if( $pretty == $WRAPPED) --- Show quoted text
> if( ($pretty == $WRAPPED) || ($pretty == $INDENTEDA) )
7111c7116,7123 < $tag .= $pretty==$NSGMLS ? "\n" : ' '; --- Show quoted text
> $tag .= ( ($pretty==$NSGMLS) || ($pretty==
$INDENTEDA) ) ? "\n" : ' '; Show quoted text
> > if( $pretty==$INDENTEDA) > { my $indent= $elt->level; > my $prefix=''; > $prefix= $INDENT x $indent; > $tag .= $prefix . ' '; > }
7164c7176 < elsif( ($pretty==$INDENTED) || ($pretty==$INDENTEDC) || ($pretty==$WRAPPED)) --- Show quoted text
> elsif( ($pretty==$INDENTED) || ($pretty==$INDENTEDA) ||
($pretty==$INDENTEDC) || ( $pretty==$WRAPPED)) 7240c7252 < elsif( ($pretty==$INDENTED) || ($pretty==$WRAPPED) ) --- Show quoted text
> elsif( ($pretty==$INDENTED) || ($pretty==$INDENTEDA) ||
($pretty==$INDENTEDC) || ( $pretty==$WRAPPED) ) 7411c7423 < if( $pretty== $WRAPPED && !$xml_space_preserve) --- Show quoted text
> if( ($pretty== $WRAPPED || $pretty== $INDENTEDA) && !
$xml_space_preserve)

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 500b
Hi Sjur, Sorry for the very late response, but RT stopped sending email notifications or a while, and I just saw the ticket. Indeed, your patch looks ok, I have applied it to the current development version at http://xmltwig.com/xmltwig/ .I had to change it a bit because I restructured that part of the code recently (since 3.29), so you might want to test the new version to see if I got it right. I now have to add tests and docs, which should be quick. Thanks a lot for the patch. __ mirod
Download (untitled) / with headers
text/plain 295b
OK, The latest version, this morning, seems to format properly (see t/test_3_30.t). Note that if you want to keep the attribute order and they are not already alphabetically sorted, you will need to use the keep_atts_order option (as in the test). Let me know if this works for you. __ mirod


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.