[jira] [Commented] (GROOVY-7874) When serializing a document with xmlUtil, namespaces that are actually necessary, are being dropped as "unused"

2016-06-25 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15349853#comment-15349853
 ] 

Paul King commented on GROOVY-7874:
---

XmlUtil like some other parts of Groovy are within normal XML spec to keep 
their current behavior. To support XML Schema processing these processors would 
also need to handle namespace-aware attributes (outside the normal spec but 
probably worth handling).

Possibly duplicating or at least overlapping GROOVY-3905.

> When serializing a document with xmlUtil, namespaces that are actually 
> necessary, are being dropped as "unused"
> ---
>
> Key: GROOVY-7874
> URL: https://issues.apache.org/jira/browse/GROOVY-7874
> Project: Groovy
>  Issue Type: Bug
>  Components: XML Processing
>Affects Versions: 2.4.3, 2.4.6, 2.4.7
> Environment: MAC OS X, and Windows
>Reporter: Mike Cargal
>Priority: Minor
>
> The following code segment demonstrates parsing a schema and then serializing 
> with xmlUtil.  xmlUtil, in it's attempt to discard necessary namespaces, is 
> discarding namespaces that are actually needed.
> Save the original schema and the referenced schema in eclipse, and there will 
> be no errors.  Save the output schema (as MyRevSchema.xsd for example) and 
> you'll have errors as a result of the dropped namespaces.
> {code}
> import groovy.xml.*
> scSrc = '''
> http://www.w3.org/2001/XMLSchema;
> attributeFormDefault="unqualified" elementFormDefault="qualified"
> targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
> xmlns:myns="urn:cargal.net/myNS">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> '''
> schema = new XmlSlurper().parseText(scSrc)
> println schema.lookupNamespace('')
> println schema.lookupNamespace('myns')
> println new XmlUtil().serialize(schema)
> {code}
> results:
> {noformat}
> urn:cargal.net/myNS
> urn:cargal.net/myNS
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
> attributeFormDefault="unqualified" elementFormDefault="qualified" 
> targetNamespace="urn:cargal.net/myNS">
>   
>   
> 
>   
> 
>   
> 
>   
> 
>   
>   
>   
> 
> {noformat}
> For reference:  MyRefSchema.xsd
> {noformat}
> 
> http://www.w3.org/2001/XMLSchema;
>   attributeFormDefault="unqualified" elementFormDefault="qualified"
>   targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
>   xmlns:myns="urn:cargal.net/myNS">
>   
>   
>   
>   
>   
>   
> 
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7874) When serializing a document with xmlUtil, namespaces that are actually necessary, are being dropped as "unused"

2016-06-25 Thread Mike Cargal (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mike Cargal updated GROOVY-7874:

Description: 
The following code segment demonstrates parsing a schema and then serializing 
with xmlUtil.  xmlUtil, in it's attempt to discard necessary namespaces, is 
discarding namespaces that are actually needed.

Save the original schema and the referenced schema in eclipse, and there will 
be no errors.  Save the output schema (as MyRevSchema.xsd for example) and 
you'll have errors as a result of the dropped namespaces.

{code}
import groovy.xml.*

scSrc = '''
http://www.w3.org/2001/XMLSchema;
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
xmlns:myns="urn:cargal.net/myNS">













'''

schema = new XmlSlurper().parseText(scSrc)
println schema.lookupNamespace('')
println schema.lookupNamespace('myns')
println new XmlUtil().serialize(schema)
{code}

results:
{noformat}
urn:cargal.net/myNS
urn:cargal.net/myNS
http://www.w3.org/2001/XMLSchema; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS">
  
  

  

  

  

  
  
  

{noformat}

For reference:  MyRefSchema.xsd
{noformat}

http://www.w3.org/2001/XMLSchema;
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
xmlns:myns="urn:cargal.net/myNS">







{noformat}

  was:
The following code segment demonstrates parsing a schema and then serializing 
with xmlUtil.  xmlUtil, in it's attempt to discard necessary namespaces, is 
discarding namespaces that are actually needed.

Save the original schema and the referenced schema in eclipse, and there will 
be no errors.  Save the output schema (as MyRevSchema.xsd for example) and 
you'll have errors as a result of the dropped namespaces.

{code}
import groovy.xml.*

scSrc = '''
http://www.w3.org/2001/XMLSchema;
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
xmlns:myns="urn:cargal.net/myNS">













'''

schema = new XmlSlurper().parseText(scSrc)
println schema.lookupNamespace('')
println schema.lookupNamespace('myns')
println new XmlUtil().serialize(schema)
{code}

results:
{noformat}
schema.@attributeFormDefault=unqualified
schema.@xmlns=
http://www.w3.org/2001/XMLSchema; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS">
  
  

  

  

  

  
  
  

{noformat}

For reference:  MyRefSchema.xsd
{noformat}

http://www.w3.org/2001/XMLSchema;
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
xmlns:myns="urn:cargal.net/myNS">







{noformat}


> When serializing a document with xmlUtil, namespaces that are actually 
> necessary, are being dropped as "unused"
> ---
>
> Key: GROOVY-7874
> URL: https://issues.apache.org/jira/browse/GROOVY-7874
> Project: Groovy
>  Issue Type: Bug
>  Components: XML Processing
>Affects Versions: 2.4.3, 2.4.6, 2.4.7
> Environment: MAC OS X, and Windows
>Reporter: Mike Cargal
>Priority: Minor
>
> The following code segment demonstrates parsing a schema and then serializing 
> with xmlUtil.  xmlUtil, in it's attempt to discard necessary namespaces, is 
> discarding namespaces that are actually needed.
> Save the original schema and the referenced schema in eclipse, and there will 
> be no errors.  Save the output schema (as MyRevSchema.xsd for example) and 
> you'll have errors as a result of the dropped namespaces.
> {code}
> import groovy.xml.*
> scSrc = '''
> http://www.w3.org/2001/XMLSchema;
> attributeFormDefault="unqualified" elementFormDefault="qualified"
> targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
> xmlns:myns="urn:cargal.net/myNS">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> '''
> schema = new XmlSlurper().parseText(scSrc)
> println schema.lookupNamespace('')
> println 

[jira] [Updated] (GROOVY-7874) When serializing a document with xmlUtil, namespaces that are actually necessary, are being dropped as "unused"

2016-06-25 Thread Mike Cargal (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mike Cargal updated GROOVY-7874:

Description: 
The following code segment demonstrates parsing a schema and then serializing 
with xmlUtil.  xmlUtil, in it's attempt to discard necessary namespaces, is 
discarding namespaces that are actually needed.

Save the original schema and the referenced schema in eclipse, and there will 
be no errors.  Save the output schema (as MyRevSchema.xsd for example) and 
you'll have errors as a result of the dropped namespaces.

{code}
import groovy.xml.*

scSrc = '''
http://www.w3.org/2001/XMLSchema;
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
xmlns:myns="urn:cargal.net/myNS">













'''

schema = new XmlSlurper().parseText(scSrc)
println schema.lookupNamespace('')
println schema.lookupNamespace('myns')
println new XmlUtil().serialize(schema)
{code}

results:
{noformat}
schema.@attributeFormDefault=unqualified
schema.@xmlns=
http://www.w3.org/2001/XMLSchema; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS">
  
  

  

  

  

  
  
  

{noformat}

For reference:  MyRefSchema.xsd
{noformat}

http://www.w3.org/2001/XMLSchema;
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
xmlns:myns="urn:cargal.net/myNS">







{noformat}

  was:
When parsing an XML document with XmlSlurper, some attributes are being dropped.
{code}
import groovy.xml.*

scSrc = '''http://www.w3.org/2001/XMLSchema; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS" 
xmlns="urn:cargal.net/myNS">


'''

schema = new XmlSlurper().parseText(scSrc)
println "schema.@attributeFormDefault=${schema.@attributeFormDefault}"
println "schema.@xmlns=${schema.@xmlns}"
println new XmlUtil().serialize(schema)
{code}

results:
{noformat}
schema.@attributeFormDefault=unqualified
schema.@xmlns=
http://www.w3.org/2001/XMLSchema; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS">
  

{noformat}


Summary: When serializing a document with xmlUtil, namespaces that are 
actually necessary, are being dropped as "unused"  (was: XmlSlurper is dropping 
root node attributes)

I've revised the description to reflect the problem being in xmlUtil, and that 
it is too aggressive in removing namespaces it believes to be unnecessary, with 
an example of how the  resulting schema is no longer valid (while the input 
schema, without the dropped namespaces, was valid)

> When serializing a document with xmlUtil, namespaces that are actually 
> necessary, are being dropped as "unused"
> ---
>
> Key: GROOVY-7874
> URL: https://issues.apache.org/jira/browse/GROOVY-7874
> Project: Groovy
>  Issue Type: Bug
>  Components: XML Processing
>Affects Versions: 2.4.3, 2.4.6, 2.4.7
> Environment: MAC OS X, and Windows
>Reporter: Mike Cargal
>Priority: Minor
>
> The following code segment demonstrates parsing a schema and then serializing 
> with xmlUtil.  xmlUtil, in it's attempt to discard necessary namespaces, is 
> discarding namespaces that are actually needed.
> Save the original schema and the referenced schema in eclipse, and there will 
> be no errors.  Save the output schema (as MyRevSchema.xsd for example) and 
> you'll have errors as a result of the dropped namespaces.
> {code}
> import groovy.xml.*
> scSrc = '''
> http://www.w3.org/2001/XMLSchema;
> attributeFormDefault="unqualified" elementFormDefault="qualified"
> targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS"
> xmlns:myns="urn:cargal.net/myNS">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> '''
> schema = new XmlSlurper().parseText(scSrc)
> println schema.lookupNamespace('')
> println schema.lookupNamespace('myns')
> println new XmlUtil().serialize(schema)
> {code}
> results:
> {noformat}
> schema.@attributeFormDefault=unqualified
> schema.@xmlns=
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
> attributeFormDefault="unqualified" elementFormDefault="qualified" 
> targetNamespace="urn:cargal.net/myNS">
>   
>   
> 
>   
> 
>   
> 
>   
> 
>   

[jira] [Commented] (GROOVY-7874) XmlSlurper is dropping root node attributes

2016-06-25 Thread Mike Cargal (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15349507#comment-15349507
 ] 

Mike Cargal commented on GROOVY-7874:
-

Thanks, it helps to know that XmlSlurper identifies and handles namespaces 
differently than other attributes.

I had thought about the possibility that the serialization thought these were 
unused namespace when I looked at the namespaces that were dropped.

I stripped this down for the example. In my "real" problem, I'm modifying and 
rewriting schemas that are included from other schemas (and themselves include 
schemas).  I'm getting errors in eclipse on these schemas that I can correct by 
placing those two namespaces back into these schemas. So it appears that they 
are being used even if it's not entirely clear in the context of the single psd 
file. It seems that it might be getting too clever in removing "unused" 
namespaces.  

I'll try to look a bit further into what's going on and update this.  (i.e. 
provide an example that demonstrates how these removals actually cause a 
problem.)

thanks

Just curious, in the mean time, is there some work around for me to get these 
namespaces forced back into my output?

> XmlSlurper is dropping root node attributes
> ---
>
> Key: GROOVY-7874
> URL: https://issues.apache.org/jira/browse/GROOVY-7874
> Project: Groovy
>  Issue Type: Bug
>  Components: XML Processing
>Affects Versions: 2.4.3, 2.4.6, 2.4.7
> Environment: MAC OS X, and Windows
>Reporter: Mike Cargal
>Priority: Minor
>
> When parsing an XML document with XmlSlurper, some attributes are being 
> dropped.
> {code}
> import groovy.xml.*
> scSrc = ''' xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
> attributeFormDefault="unqualified" elementFormDefault="qualified" 
> targetNamespace="urn:cargal.net/myNS" xmlns="urn:cargal.net/myNS">
> 
> 
> '''
> schema = new XmlSlurper().parseText(scSrc)
> println "schema.@attributeFormDefault=${schema.@attributeFormDefault}"
> println "schema.@xmlns=${schema.@xmlns}"
> println new XmlUtil().serialize(schema)
> {code}
> results:
> {noformat}
> schema.@attributeFormDefault=unqualified
> schema.@xmlns=
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
> attributeFormDefault="unqualified" elementFormDefault="qualified" 
> targetNamespace="urn:cargal.net/myNS">
>   
> 
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] groovy pull request #348: Groovy7860 AutoImplement transform

2016-06-25 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/348#discussion_r68484985
  
--- Diff: src/main/groovy/transform/Undefined.java ---
@@ -28,6 +28,10 @@
 private Undefined() {}
 public static final String STRING = 
"";
 public static final class CLASS {}
+public static final class UNDEFINED_EXCEPTION extends RuntimeException 
{
--- End diff --

Changed. Thanks for the suggestion.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Resolved] (GROOVY-7860) Groovy could implement an @AutoImplement transform

2016-06-25 Thread Paul King (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7860?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King resolved GROOVY-7860.
---
   Resolution: Fixed
Fix Version/s: 2.5.0-beta-1

PR merged

> Groovy could implement an @AutoImplement transform
> --
>
> Key: GROOVY-7860
> URL: https://issues.apache.org/jira/browse/GROOVY-7860
> Project: Groovy
>  Issue Type: New Feature
>Reporter: Paul King
>Assignee: Paul King
> Fix For: 2.5.0-beta-1
>
>
> Groovy provides numerous facilities for dynamically creating 'Proxy' 
> implementations of interfaces, e.g.:
> {code}
> def emptyIterator = [hasNext: { false }] as Iterator
> {code}
> There is special support for Closures, maps of Closures, SAM method coercion 
> and various proxy generator classes. Typically such dynamic creation is 
> exactly what is required, e.g. a one-off usage object or a testing stub of 
> some kind. But other times, compile time creation of such classes would be 
> useful. This proposal suggests a transform to reduce boilerplate code for a 
> number of common scenarios where code can be created. The proposal has 
> numerous configuration options but doesn't try to support everything that the 
> dynamic options provide. E.g. no map of Closures is supported; you _can_ just 
> create a class manually in that case.
> The transform allows the above example to be as follows:
> {code}
> @AutoImplement
> class EmptyStringIterator implements Iterator {
> boolean hasNext() { false }
> }
> {code}
> which provides a method having signature '{{String next()}}' with an 
> implementation that returns the default value for the return type ({{null}} 
> for {{String}}).
> Alternatively, we can make it throw an exception as follows:
> {code}
> @AutoImplement(exception=UnsupportedOperationException)
> class EmptyStringIterator implements Iterator {
> boolean hasNext() { false }
> }
> {code}
> This would in fact be a closer match to the initial dynamic case shown above.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)