This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 379705 - Add support equivalent to JAXB RI's Canonicalization support
Summary: Add support equivalent to JAXB RI's Canonicalization support
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-16 11:14 EDT by Rick Barkhouse CLA
Modified: 2022-06-09 10:05 EDT (History)
2 users (show)

See Also:


Attachments
Test case (2.40 KB, application/x-zip-compressed)
2012-05-23 10:06 EDT, Rick Barkhouse CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Rick Barkhouse CLA 2012-05-23 10:00:25 EDT
http://www.w3.org/TR/xml-c14n

* The document is encoded in UTF-8
* Line breaks normalized to #xA on input, before parsing
* Attribute values are normalized, as if by a validating processor
* Character and parsed entity references are replaced
* CDATA sections are replaced with their character content
* The XML declaration and document type declaration (DTD) are removed
* Empty elements are converted to start-end tag pairs
* Whitespace outside of the document element and within start and end tags is normalized
* All whitespace in character content is retained (excluding characters removed during line feed normalization)
* Attribute value delimiters are set to quotation marks (double quotes)
* Special characters in attribute values and character content are replaced by character references
* Superfluous namespace declarations are removed from each element
* Default attributes are added to each element
* Lexicographic order is imposed on the namespace declarations and attributes of each element
Comment 2 Rick Barkhouse CLA 2012-05-23 10:02:51 EDT
Using Apache security canonicalizer:

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.newDocument();
marshaller.marshal(obj, doc);

doc.normalize();
Init.init();
byte[] c14nOutputbytes = Canonicalizer.getInstance(
    Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS)
    .canonicalizeSubtree(doc.getDocumentElement());
// Re-parse to get attributes in alpha order
Document canonical = db.parse(new ByteArrayInputStream(c14nOutputbytes));
Comment 3 Rick Barkhouse CLA 2012-05-23 10:06:25 EDT
Created attachment 216127 [details]
Test case
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:05:40 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink