MyBatis: Error when adding a 'bind' inside of 'foreach' - mybatis

I'm using MyBatis for handling SQL queries. Here is my problematic piece of code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.foo.Foo">
...
<insert id="insert" parameterType="com.foo.FooParam">
<foreach collection="bars" item="bar" separator=" ">
<bind name="inFavorites" value="bar.sectionId == '_favorites'" />
<foreach collection="bar.bars2" item="bar2" index="index" separator=" ">
...
</foreach>
</foreach>
</insert>
...
</mapper>
Intelij shows the following error when validiting the xml:
Error:(24, 74) Element type "bind" must be declared.
Error:(28, 19) The content of element type "foreach" must match "(include|trim|where|set|foreach|choose|if)".
And when i put a compiled module as an osgi package in a jetty server (mvn compiles it w/o errors and warnings) I'm getting the following error:
lineNumber: 28; columnNumber: 19; The content of element type "foreach"
must match "(include|trim|where|set|foreach|choose|if)".
So Ok, I get this. I cannot add a 'bind' element inside of a 'foreach'.
But why, if http://mybatis.org/dtd/mybatis-3-mapper.dtd says otherwise?
<!ELEMENT foreach (#PCDATA | include | trim | where | set | foreach | choose | if | bind)*>

bind inside foreach is allowed since version 3.2.3. You are obviously using an older version.
dtd file is not downloaded from the internet but the version packaged in mybatis jar is used.

Related

When parsing the typeAliases tag with package as a subtag in the mybatis framework, a parsing error occurs. I used jdk9 as a development environment

Environment Configure
jdk9
mybatis v3.5.4
MacOS
Description
When I was studying Mybatis, I encountered confusing questions. The configuration in question is as follows:
<configuration>
<typeAliases>
<package name="com.xxx.entity" />
</typeAliases>
</configuration>
The code to start mybatis is as follows:
// the var of CONFIG_LOCATION is the url for mybatis configure
Reader config = Resources.getResourceAsStream(CONFIG_LOCATION);
SqlSessionFactory sqlSessioinFactory = new SqlSessionFactoryBuilder().build(config);
When parsing the typeAliases tag, if the subtag is package, an exception will be thrown:
Error building SqlSession.
The error may exist in SQL Mapper Configuration
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.nio.file.InvalidPathException: Nul character not allowed: com/akamonk/ruixun/entity/Cart.class/����5+ " # $ %
at org.mybatis#3.5.4/org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.mybatis#3.5.4/org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
at org.mybatis#3.5.4/org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)
at s2.project/com.akamonk.ruixun.listener.ContextLoader.initContext(ContextLoader.java:39)
at s2.project/com.akamonk.ruixun.listener.ContextLoader.main(ContextLoader.java:59)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.nio.file.InvalidPathException: Nul character not allowed: com/akamonk/ruixun/entity/Cart.class/����5+ " # $ %
at org.mybatis#3.5.4/org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:121)
at org.mybatis#3.5.4/org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:98)
at org.mybatis#3.5.4/org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:78)
... 3 more
Caused by: java.nio.file.InvalidPathException: Nul character not allowed: com/akamonk/ruixun/entity/Cart.class/����5+ " # $ %
at java.base/sun.nio.fs.UnixPath.checkNotNul(UnixPath.java:91)
at java.base/sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:81)
at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69)
at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:280)
at java.base/jdk.internal.module.Resources.toSafeFilePath(Resources.java:138)
at java.base/jdk.internal.module.Resources.toFilePath(Resources.java:97)
at java.base/jdk.internal.module.ModuleReferences$ExplodedModuleReader.find(ModuleReferences.java:384)
at java.base/jdk.internal.loader.BuiltinClassLoader$2.run(BuiltinClassLoader.java:408)
at java.base/jdk.internal.loader.BuiltinClassLoader$2.run(BuiltinClassLoader.java:403)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/jdk.internal.loader.BuiltinClassLoader.findMiscResource(BuiltinClassLoader.java:402)
at java.base/jdk.internal.loader.BuiltinClassLoader.findResources(BuiltinClassLoader.java:333)
at java.base/java.lang.ClassLoader.getResources(ClassLoader.java:1457)
at org.mybatis#3.5.4/org.apache.ibatis.io.VFS.getResources(VFS.java:171)
at org.mybatis#3.5.4/org.apache.ibatis.io.DefaultVFS.list(DefaultVFS.java:105)
at org.mybatis#3.5.4/org.apache.ibatis.io.DefaultVFS.list(DefaultVFS.java:153)
at org.mybatis#3.5.4/org.apache.ibatis.io.VFS.list(VFS.java:200)
at org.mybatis#3.5.4/org.apache.ibatis.io.ResolverUtil.find(ResolverUtil.java:220)
at org.mybatis#3.5.4/org.apache.ibatis.type.TypeAliasRegistry.registerAliases(TypeAliasRegistry.java:130)
at org.mybatis#3.5.4/org.apache.ibatis.type.TypeAliasRegistry.registerAliases(TypeAliasRegistry.java:125)
at org.mybatis#3.5.4/org.apache.ibatis.builder.xml.XMLConfigBuilder.typeAliasesElement(XMLConfigBuilder.java:164)
at org.mybatis#3.5.4/org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:109)
... 5 more
At this time, the content of module-info.java is as follows
open module mybatis.test {
requires org.mybatis;
requires java.sql;
}
There is a strange phenomenon, when I remove the module-info.java from the project, mybatis will not have problems when parsing typeAliases.Therefore, my bold guess is caused by JDK9. But I don't know how to solve it and the specific cause of the problem

Cannot add XML fragment based on node attribute name

We have version 7.0.12. We're trying to add a new fragment to the following XML using the 'Insert XML fragment into XML Files' action:
<?xml version="1.0" encoding="UTF-8"?>
<ConnectorData>
<Events>
<Event id="ReportPrinting"></Event>
</Events>
</ConnectorData>
we've used the following xPath Expression to locate the node with attribute id="ReportPrinting"
/ConnectorData/Events/Event[id='ReportPrinting']
unfortunately, this fails with the following log entry:
[INFO] com.install4j.runtime.beans.actions.xml.InsertXmlFragmentAction [ID 59]: Execute action
Property files: [EventComponents.xml]
Property fragmentFile: null
Property fragmentInsertMode: Insert as last child
Property fragmentSource: Direct entry
Property fragmentText: <EventComponent ProductID="SmartOrganizer" ComponentID="RoomClose">
<ExecutionOrdering>1</ExecutionOrdering>
<BreakExecution BreakOn="True">true</BreakExecution>
</EventComponent>
Property xpathExpression: /ConnectorData/Events/Event[id='ReportPrinting']
Property downloadExternalEntities: false
Property rollbackSupported: true
Property validating: false
Backing up C:\Program Files (x86)\Test\EventComponents.xml
[ERROR] com.install4j.runtime.beans.actions.xml.InsertXmlFragmentAction [ID 59]: No nodes found for XPath /ConnectorData/Events/Event[id='ReportPrinting']
Execute action not successful after 23 ms
Do you have any idea why this might fail?
Attributes are referenced as #id in XPath expressions. So your XPath should be
/ConnectorData/Events/Event[#id='ReportPrinting']

Mybatis Generator: What's the best way to separate out "auto generated" and "hand edited files"

I am on a project that uses both Mybatis (for persisting java to database) and Mybatis Generator (to automatically generate the mapper xml files and java interfaces from a database schema).
Mybatis generator does a good job at generating the files necessary for basic crud operation.
Context
For some of the tables/classes, we will need more "stuff" (code queries, etc) than the "crud stuff" generated by the MyBatis Generator tool.
Is there any way to have "best of both worlds", i.e use auto generation as as well as "custom code". How do you separate out and structure the "hand edited files" and "automatically generated files".
Proposal
I was thinking about the following, i.e. for table "Foo"
Auto-Generated
FooCrudMapper.xml
interface FooCrud.java
(where "Crud" stands for "Create Read Update Delete")
Hand Edited
FooMapper.xml
interface Foo extends FooCrud
The notion: if the schema changed, you could always safely autogenerate the "Crud" xml and .java files without wiping out any of the custom changes.
Questions
Would mybatis correctly handle this scenario, i.e. would this mapper correctly execute the auto-generated 'crud code'?
FooMapper fooMapper = sqlSession.getMapper(FooMapper.class);
What approach do you recommend?
Edit 1:
* Our db design uses a 'core table' ("element") with other tables 'extending' that table and adding extra attributes (shared key) . I've looked at docs and source concluded that I cannot use Mybatis Generator in conjunction with such 'extension' without any hand editing:
i.e. This does not work.
-ElementMapper extends "ElementCrudMapper"
-FooMapper.xml extends both "ElementCrudMapper" and "FooCrudMapper"
thanks all!
I can seperate out generated files and hand edited files.
I use mybatis-spring and spring to manage dao interfaces. This library allows MyBatis to participate in Spring transactions, takes care of building MyBatis mappers and SqlSessions and inject them into other beans, translates MyBatis exceptions into Spring DataAccessExceptions, and finally, it lets you build your application code free of dependencies on MyBatis, Spring or MyBatis-Spring.
For DAO Interfaces, I write a generic MybatisBaseDao to represent base interface generated by mybatis generator.
public interface MybatisBaseDao<T, PK extends Serializable, E> {
int countByExample(E example);
int deleteByExample(E example);
int deleteByPrimaryKey(PK id);
int insert(T record);
int insertSelective(T record);
List<T> selectByExample(E example);
T selectByPrimaryKey(PK id);
int updateByExampleSelective(#Param("record") T record, #Param("example") E example);
int updateByExample(#Param("record") T record, #Param("example") E example);
int updateByPrimaryKeySelective(T record);
int updateByPrimaryKey(T record);
}
Of course, you can custom your BaseDao according to your demand. For example we have a UserDao, Then you can defind it like this
public interface UserDao extends MybatisBaseDao<User, Integer, UserExample>{
List<User> selectUserByAddress(String address); // hand edited query method
}
For mapper xml files, I create two packages in mapper(.xml) base folder to separate generated files and hand edited files. For UserDao above, I put UserMapper.xml generated by generator in package named 'generated'. I put all hand writing mapper sqls into another UserMapper.xml file in the package named manual. The two mapper files start with the same header <mapper namespace="com.xxx.dao.UserDao" >. Mybatis can scan the xml mapper files to map sql and corresponding interface method automatically.
For generated entities and example objects I overwrite them directly.
I hope the method above can help you!
The Larry.Z solution help me to solve the same problem to separate auto generated from hand edited files. I had a custom folder structure in my project and adapted Larry solution to work in my project and add this answer to help other by use Larry solution adapting it.
The best solution is to add feature to Mybatis generator (MBG) to integrate hand modified xml mapper. MBG had to be added parsing features to add corresponding hand node method to client mapper interface but right now this features do not exist so I use and adapted Larry.Z solution.
In my project I use:
<properties>
...
<java.version>1.7</java.version>
<spring.version>3.2.2.RELEASE</spring.version>
<mybatis.version>3.2.2</mybatis.version>
<mybatis-spring.version>1.2.0</mybatis-spring.version>
<mybatis-generator-core.version>1.3.2</mybatis-generator-core.version>
...
</properties>
My folder structure is:
<base>/dao/: MBG generated dao class
<base>/dao/extended/: Extended generated class (<DaoGeneratedName>Extended)
<base>/sqlmap/: MBG generated client Interface and corresponding xml mapper
<base>/sqlmap/extended/:
hand xml mapper and hand client Interface
(<InterfaceGenerated>Extended extends InterfaceGenerated {...)
<base>/sqlmap/generated/: copy of MBG generated mapper namespace changed
I have configured Mybatis - spring
<bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="<base>.sqlmap"
p:sqlSessionTemplate-ref="sqlSessionTemplate"
p:nameGenerator-ref="myBeanNameGenerator"
/>
Implement myBeanNameGenerator only if you need to have custom name like me. In this example you can delete row p:nameGenerator-ref="myBeanNameGenerator"
If all your client Interfaces become extended you can substitute above
p:basePackage="<base>.sqlmap.extended"
(my project configuration is huge so I have extract most important bit )
This is an example of my client interface and mapper hand coded:
import <base>.dao.Countries;
import <base>.sqlmap.CountriesMapper;
import org.apache.ibatis.annotations.Param;
public interface CountriesMapperExtended extends CountriesMapper {
/**
*
* #param code
* #return
*/
Countries selectByCountryCode(#Param("code") String code);
}
Where CountriesMapper is the client interface MBG generated
The hand coded correlated xml mapper is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="<base>.sqlmap.extended.CountriesMapperExtended">
<select id="selectByCountryCode" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from countries co
where co.countrycode = #{code,jdbcType=VARCHAR}
</select>
</mapper>
To make all work I have to integrate in xml mapper all interface method MBG generated and, to do this, I copied MBG generated xml mapper in <base>/sqlmap/generated/ and change his namespace:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="<base>.sqlmap.extended.CountriesMapperExtended">
... unchanged ...
</mapper>
The problem raise when db change and I have to use MBG to reflect the new db structure.
So I have create quickly a bash script that watch in <base>/sqlmap/extended/ and check if there is an hand coded xml mapper. If there is hand coded xml mapper, copy corresponding MBG generated changing his namespace.
All this code is not an graceful solution but works.
The bash script overwrite file in <base>/sqlmap/generated/ so, not put in this folder your code.
Make a backup copy of your project and modify the bash script, to custom it and use on your responsibility.
#!/bin/bash
CURDIR="$(pwd)"
SCRIPT_DIR=`dirname $0`
usage()
{
cat << EOF
usage: $0 options
This script is usefull to generate xml map to extend mybatis
generator client interfaces. It suppose this structure:
<base>/sqlmap/ : generated xml mapper and interfaces
<base>/sqlmap/extended/ : extended xml mapper and interfaces
<base>/sqlmap/generated/ : copy of generated xml mapper changing
its namespace
If exist a mapper xml in <base>/sqlmap/extend identify by a name
ending in Extended this script generate a copy of original generated
xml map of extended interface changing then namespace to reflect the
extended Interface in <base>/sqlmap/generated.
This script require a list of base path:
$0 path1 path2 ...
Required parameters are marked by an *
OPTIONS:
-h, --help Show this message
EOF
}
declare -a BASES
let INDEX=0
TEMP=`getopt -o "hb:" --long "help,base:" -n "$0" -- "$#"`
eval set -- "$TEMP"
while true ; do
case "$1" in
-h|--help)
usage
exit 1 ;;
--)
shift ;
break ;;
*)
echo "Too mutch parametes!!! abort." ;
exit 1 ;;
esac
done
#process all paths
let INDEX=0
BASE="$1"
while [ "${BASE:0:1}" == "/" ]
do
shift ;
BASES[$INDEX]="$BASE"
let INDEX+=1
BASE="$1"
done
if [ "$INDEX" -le "0" ]
then
echo "--bases options cannot be emplty"
usage
exit 1
fi
for BASE in ${BASES[#]}
do
if [ ! -d "$BASE" ]
then
echo "Error: every base parameter must be a folder!!"
echo "Base=$BASE is not a folder"
usage
exit 1
fi
SQLMAP="$BASE/sqlmap"
if [ ! -d "$SQLMAP" ]
then
echo "Error: every base parameter must have a sqlmap folder!!"
echo "$SQLMAP is not a folder"
usage
exit 1
fi
EXTENDED="$BASE/sqlmap/extended"
if [ ! -d "$EXTENDED" ]
then
echo "Error: every base parameter must have a sqlmap/extended folder!!"
echo "$EXTENDED is not a folder"
usage
exit 1
fi
GENERATED="$BASE/sqlmap/generated"
if [ ! -d "$GENERATED" ]
then
mkdir -p "$GENERATED"
fi
while IFS= read -r -d '' file
do
name="${file##*/}"
#path="${file%/*}"
ext=".${name##*.}"
nameNoSuffix="${name%$ext}"
nameBase="${nameNoSuffix%Extended}"
sed -r 's/<mapper namespace="(.+)\.([^."]+)"\s*>\s*$/<mapper namespace="\1.extended.\2Extended">/' "$SQLMAP/$nameBase.xml" > "$GENERATED/$nameNoSuffix.xml"
done < <(eval "find $EXTENDED/ -type f -name \*Extended\.xml -print0")
done
exit 0
Use of the script
$ ./post-generator.sh "/home/...<base>" do not put the last / on path
This path is the path to the folder that contains sqlmap, sqlmap/extended, sqlmap/generated
You can use a list of path if you, like me, have more then one
To use it by maven, I use this plugin in project pom.xml:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.2.1</version>
<executions>
<execution>
<id>build client extended xml</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${basedir}/scripts/post-generator.sh</executable>
<workingDirectory>${basedir}/scripts</workingDirectory>
<arguments>
<argument>${basedir}/<basepath1></argument>
<argument>${basedir}/<basepath2></argument>
</arguments>
</configuration>
</plugin>
On project folder you can use $ mvn exec:exec
or $ mvn mybatis-generator:generate exec:exec
If you use Netbeans you can configure a project action to run these goals mybatis-generator:generate exec:exec without left Netbeans. You can start it by hand when you have a change in db structure.
Now you can work on exended mapper without problem and let MBG do his work if db structure change.
In your bean you can inject extended interface that have
automatic generated MBG methods plus your hand coded methods:
<bean id="service" class="<base>.services.ServiceImpl" scope="singleton"
...
p:countriesMapper-ref="countriesMapperExtended"
...
p:sqlSessionTemplate-ref="sqlSessionTemplate"
/>
Where countriesMapperExtended bean is generated by mapperScanner above.
I have give a working answer but it's complex and not easy to understand due to the huge configurations.
Now I have found a better and more concise and easy answer.
I'm inspired by Emacarron's post: Fix #35
I have use mbg and in generatorConfig.xml I put <javaClientGenerator type="XMLMAPPER" ...> to generate java interface and xml map configuration on folder mapper.
so in my example on mapper folder I have:
AnagraficaMapper.java
AnafigraficaMapper.xml
in model folder I have
Anagrafica.java
AnagraficaKey.java
AnagraficaExample.java
The first two are object model and extend they is trivial.
To extends mapper I simply copy and empty
AnagraficaMapper.java --> AnagraficaExMapper.java
AnagraficaMapper.xml --> AnagraficaExMapper.xml
in this two new file I put my new code.
Making an example I decide to add a new sql selectByPrimaryKeyMy
public interface AnagraficaExMapper extends AnagraficaMapper {
Anagrafica selectByPrimaryKeyMy(AnagraficaKey key);
}
This is my interface extending mgb generated AnagraficaMapper interface.
in AnagraficaExMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.algoritmica.ciaomondo.mapper.AnagraficaExMapper" >
<select id="selectByPrimaryKeyMy" parameterType="net.algoritmica.ciaomondo.model.AnagraficaKey" resultMap="net.algoritmica.ciaomondo.mapper.AnagraficaMapper.BaseResultMap">
select
<include refid="net.algoritmica.ciaomondo.mapper.AnagraficaMapper.Base_Column_List" />
from ANAGRAFICA anag
where anag.IDANAGRAFICA = #{idanagrafica,jdbcType=INTEGER}
</select>
</mapper>
How can you see the namespace is ...AnagraficaExMapper pointing to the new extending interface.
By the solution on Fix #35 when MyBatis searched for code in AnagraficaExMapper.java and found selectByPrimaryKeyMy method, this was founded in AnagraficaExMapper.xml too;
but when searched for hierarchic method like selectByPrimaryKey this was not found in AnagraficaExMapper.xml but thank to Fix #35 the code was searched on parent name too, binding all extended interfeces method in the old AnagraficaMapper.xml
To include fragment included in old xml file you have to use a full path to old xml file like in: <include refid="net.algoritmica.ciaomondo.mapper.AnagraficaMapper.Base_Column_List" />
Now you can simply have to configure MyBatis for automatic mapper scan and all interfaces where correctly bounded to xml mapper.
when you use mbg to feel db change the interface was regenerate but new extending interface are not override so your code is save.
regards
I had this task in Spring Boot project and was resolved bellow
In mybatis/*.xml files i changed generated like this <mapper namespace="news.project.demo.mappers.BrandMapper"> to
<mapper namespace="news.project.demo.mappers.extended.BrandMapperExtended">
But all sql logic must be written in xml-files. Interfaces are only declarations without #Select or #ResultMap annotations, so you must configure correctly your mybatis-generator.
in application.properties i have
mybatis.mapper-locations=classpath*:mybatis/*.xml
mybatis.type-aliases-package=news.project.demo.models

How do I config xml namespace for a smooks input file using WSO2?

I couldn't find any advices on how to setup Smooks (on WSO2 Developer Studio 3.1) in order to it properly read a xml input which has a namespace declaration.
Without the namespace the transformation works just fine!
By informing the xmlns in the input, I get this exception:
Error on line 5, column 19 in free-marker-template
Expecting a string, date or number here, Expression .vars["order"]["order-items/order-item/#id"] is instead a freemarker.ext.dom.NodeListModel
The problematic instruction:
----------
==> ${.vars["order"]["order-items/order-item/#id"]} [on line 5, column 17 in free-marker-template]
These are both my input and output:
<order id='444' xmlns="http://example.com">
<header>
<customer number="555">Amila</customer>
</header>
<order-items>
<order-item id='1'>
<product>1</product>
<quantity>2</quantity>
<price>400</price>
</order-item>
</order-items>
</order>
<salesorder>
<details>
<orderid></orderid>
<customer>
<id></id>
<name></name>
</customer>
</details>
<itemList>
<item>
<id></id>
<productId></productId>
<quantity></quantity>
<price></price>
</item>
</itemList>
</salesorder>
I've also tried Smooks core´s namespace declarations as per Smooks site:
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
>
<core:namespaces>
<core:namespace prefix="ex" uri="http://example.com/"/>
</core:namespaces>
But it seems not to be supported in the IDE since the configuration editor raises this exception:
-Value 'org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl#53abd5a9 (mixed: null, anyAttribute: null)' is not legal. (platform:/resource/Corp/smooks-config.xml,6,20)
Well, any idea?
Instead of Smooks, can't you use a XSLT? It will avoid the namespace issue you have.

Querying svc log file with logParser

I have generated a xml trace for my program using the Enterprise Library TraceManager. It works great. Using the Microsoft Service Trace Viewer, I can see a separate trace per call.
I would love to query the file so I found Microsoft Logparser and was hopeful I could use that. Unfortunately, I cannot figure out the expected input format. Input of XML returns a error of more than one root node found for the document. None of the other format parse the correct number of line.
Has anyone had any success querying a SVCLog File
TraceManager traceManager
traceManager = EnterpriseLibraryContainer.Current.GetInstance<TraceManager>();
TraceLogEntry traceEntry = new TraceLogEntry();
using (this.traceManager.StartTrace("Tracing")){
traceEntry.Title = "Message";
traceEntry.Priority = Priority;
this.traceManager.LogWriter.Write(traceEntry);
}
The Tracing Category is hooked up to a XML trace listener:
< loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
< listeners>
< add name="XML Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="c:\A2ISOtrace.svclog" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId" />
< /listeners>
< categorySources>
< add switchValue="All" name="Tracing">
< listeners>
< add name="XML Trace Listener" />
< /listeners>
< /add>
< /categorySources>
Log produces a number of rows like:
< E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System <EventID>1</EventID><Type>3</Type>. . . .
Since your SVCLog file is missing a root element you could embed it into a basic Xml document.
The Xml document
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE Root SYSTEM "Test.dtd">
<Root>
&svclog;
</Root>
The DTD document
<!ENTITY svclog SYSTEM "SVCLog.xml">
where you declare the ENTITY svclog importing your SVCLog file.
Now you should be able to parse the Xml input.