Skip to main content
deleted 27 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I can't write Writing GML cause acauses XML encoding error?

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?

update:

 

I am tryintrying to remove not allowed symbols from attributes and element names by using

StringBuilder sb = new StringBuilder();
if (!s.substring(0, 1).matches("[a-zA-Z_]"))
    throw new IllegalArgumentException();
sb.append(s.substring(0, 1));
for (int i = 1; i < s.length(); i++) {
    if (s.substring(i, i + 1).matches("[a-zA-Z0-9_.-]")) {
    sb.append(s.substring(i, i + 1));
    }
}
return sb.toString();

to sanitize shape feature attribute's values. Now attributes looks good but I am still getting the same exception. As I say 

I am new to GIS and org.geotools, any hint is appreciated.

I can't write GML cause a XML encoding error

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?

update:

I am tryin to remove not allowed symbols from attributes and element names by using

StringBuilder sb = new StringBuilder();
if (!s.substring(0, 1).matches("[a-zA-Z_]"))
    throw new IllegalArgumentException();
sb.append(s.substring(0, 1));
for (int i = 1; i < s.length(); i++) {
    if (s.substring(i, i + 1).matches("[a-zA-Z0-9_.-]")) {
    sb.append(s.substring(i, i + 1));
    }
}
return sb.toString();

to sanitize shape feature attribute's values. Now attributes looks good but I am still getting the same exception. As I say I am new to GIS and org.geotools, any hint is appreciated.

Writing GML causes XML encoding error?

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?

 

I am trying to remove not allowed symbols from attributes and element names by using

StringBuilder sb = new StringBuilder();
if (!s.substring(0, 1).matches("[a-zA-Z_]"))
    throw new IllegalArgumentException();
sb.append(s.substring(0, 1));
for (int i = 1; i < s.length(); i++) {
    if (s.substring(i, i + 1).matches("[a-zA-Z0-9_.-]")) {
    sb.append(s.substring(i, i + 1));
    }
}
return sb.toString();

to sanitize shape feature attribute's values. Now attributes looks good but I am still getting the same exception. 

I am new to GIS and org.geotools.

added 633 characters in body
Source Link
Francesco
  • 281
  • 3
  • 11

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?

update:

I am tryin to remove not allowed symbols from attributes and element names by using

StringBuilder sb = new StringBuilder();
if (!s.substring(0, 1).matches("[a-zA-Z_]"))
    throw new IllegalArgumentException();
sb.append(s.substring(0, 1));
for (int i = 1; i < s.length(); i++) {
    if (s.substring(i, i + 1).matches("[a-zA-Z0-9_.-]")) {
    sb.append(s.substring(i, i + 1));
    }
}
return sb.toString();

to sanitize shape feature attribute's values. Now attributes looks good but I am still getting the same exception. As I say I am new to GIS and org.geotools, any hint is appreciated.

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?

update:

I am tryin to remove not allowed symbols from attributes and element names by using

StringBuilder sb = new StringBuilder();
if (!s.substring(0, 1).matches("[a-zA-Z_]"))
    throw new IllegalArgumentException();
sb.append(s.substring(0, 1));
for (int i = 1; i < s.length(); i++) {
    if (s.substring(i, i + 1).matches("[a-zA-Z0-9_.-]")) {
    sb.append(s.substring(i, i + 1));
    }
}
return sb.toString();

to sanitize shape feature attribute's values. Now attributes looks good but I am still getting the same exception. As I say I am new to GIS and org.geotools, any hint is appreciated.

Source Link
Francesco
  • 281
  • 3
  • 11

I can't write GML cause a XML encoding error

I am using org.geotools version 2.7.0 and I am trying to get some shapefiles to GML 3.1.1. Sadly I got an exception:

java.lang.RuntimeException: Encode failed for _Feature. Cause: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
at org.geotools.xml.impl.ElementEncodeExecutor.visit(ElementEncodeExecutor.java:132)
at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
at org.geotools.xml.impl.ElementEncoder.encode(ElementEncoder.java:83)
at org.geotools.xml.Encoder.encode(Encoder.java:1100)
at org.geotools.xml.Encoder.encode(Encoder.java:836)
at org.geotools.xml.Encoder.encode(Encoder.java:564)

Maybe it's a space or an accented char (shape's attributes are full of accented chars) but I am very new to geotools and GIS, this error is completely blocking me. I can't find a way to specify a charset to read data from shape (by set up DataStore) or to write data into GML file (by set up Encoder). What am I missing?