Author: fanningpj Date: Sat Nov 9 11:27:24 2019 New Revision: 1869600 URL: http://svn.apache.org/viewvc?rev=1869600&view=rev Log: [XMLBEANS-548] support adding standalone flag to xml declaration
Added: xmlbeans/trunk/test/src/misc/checkin/XmlDocumentPropertiesTest.java - copied, changed from r1869598, xmlbeans/trunk/test/src/misc/checkin/VersionTest.java Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java?rev=1869600&r1=1869599&r2=1869600&view=diff ============================================================================== --- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java (original) +++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java Sat Nov 9 11:27:24 2019 @@ -913,7 +913,7 @@ abstract class Saver { Boolean standalone = null; if (props != null && props.get(XmlDocumentProperties.STANDALONE) != null) - standalone = Boolean.valueOf("yes".equals(props.get(XmlDocumentProperties.STANDALONE))); + standalone = props.getStandalone(); emit("<?xml version=\""); emit(version); Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java?rev=1869600&r1=1869599&r2=1869600&view=diff ============================================================================== --- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java (original) +++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java Sat Nov 9 11:27:24 2019 @@ -79,7 +79,10 @@ public abstract class XmlDocumentPropert /** * Returns the standalone property */ - public boolean getStandalone ( ) { return get( STANDALONE ) != null; } + public boolean getStandalone ( ) { + Object flag = get( STANDALONE ); + return flag != null && flag.toString().equalsIgnoreCase("true"); + } /** * Sets the DOCTYPE name use in the <!DOCTYPE> declaration. Copied: xmlbeans/trunk/test/src/misc/checkin/XmlDocumentPropertiesTest.java (from r1869598, xmlbeans/trunk/test/src/misc/checkin/VersionTest.java) URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/checkin/XmlDocumentPropertiesTest.java?p2=xmlbeans/trunk/test/src/misc/checkin/XmlDocumentPropertiesTest.java&p1=xmlbeans/trunk/test/src/misc/checkin/VersionTest.java&r1=1869598&r2=1869600&rev=1869600&view=diff ============================================================================== --- xmlbeans/trunk/test/src/misc/checkin/VersionTest.java (original) +++ xmlbeans/trunk/test/src/misc/checkin/XmlDocumentPropertiesTest.java Sat Nov 9 11:27:24 2019 @@ -1,4 +1,4 @@ -/* Copyright 2004 The Apache Software Foundation +/* Copyright 2019 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,19 +15,40 @@ package misc.checkin; +import java.util.HashMap; + import org.apache.xmlbeans.XmlBeans; +import org.apache.xmlbeans.XmlDocumentProperties; import org.junit.Test; -import static org.junit.Assert.assertNotNull; - -public class VersionTest { +import static org.junit.Assert.*; +public class XmlDocumentPropertiesTest { - // Test the getVersion API @Test - public void testXBeansVersion() { - String version = XmlBeans.getVersion(); - assertNotNull(version); + public void testSetStandalone() { + XmlDocumentProperties props = new XmlDocumentProperties() { + HashMap<Object, Object> props = new HashMap<>(); + @Override + public Object put ( Object key, Object value ) { + return props.put(key, value); + } + + @Override + public Object get ( Object key ) { + return props.get(key); + } + + @Override + public Object remove ( Object key ) { + return props.remove(key); + } + }; + assertFalse(props.getStandalone()); + props.setStandalone(true); + assertTrue(props.getStandalone()); + props.setStandalone(false); + assertFalse(props.getStandalone()); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org