XercesDOMParser and XIncludes - c++

I am attempting to get xincludes working in an existing system that uses a XercesDOMParser in xercesc to parse incoming xml from a client. I am working with Apache Xercesc v3.0.1, and the incoming XML, read from an input stream, is:
<?xml version="1.0" encoding="UTF-8"?>
<VisionServer xmlns:xi="http://www.w3.org/2001/XInclude">
<CompositeObject>
<xi:include href="testguioutput.xml" />
while testguioutput.xml contains
<?xml version="1.0" encoding="UTF-8"?>
<GUIOutput>
<Input>Input</Input>
<Title>IDC2_1</Title>
</GUIOutput>
The existing code uses a wrapper around a XercesDOMParser to parse the XML as it comes in, and after using setDoNamespaces and setDoXInclude to true, it is attempting to parse the XInclude, but I get a persistent "Fatal: include failed and no fallback element found in document '{0}'" error, no matter where in the directory structure I put testguioutput.xml.
I am working under visualstudio 2008, my working directory is default, and running out of /project/debug, but the include fails whether the target file is in /project/ or /project/debug/.

I was able to expand the xinclude tags using the XInclude.exe sample application that is included with the Xerces application. To do this, I created two files using your files above:
test1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<VisionServer xmlns:xi="http://www.w3.org/2001/XInclude">
<CompositeObject>
<xi:include href="test2.xml"/>
</CompositeObject>
</VisionServer>
test2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<GUIOutput>
<Input>Input</Input>
<Title>IDC2_1</Title>
</GUIOutput>
At the command line I executed:
"XInclude.exe test1.xml test1_expanded.xml" without quotes.
The resulting test1_expanded.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<VisionServer xmlns="" xmlns:xi="http://www.w3.org/2001/XInclude">
<CompositeObject>
<GUIOutput xml:base="test2.xml">
<Input>Input</Input>
<Title>IDC2_1</Title>
</GUIOutput>
</CompositeObject>
</VisionServer>

Related

BaseX 9.1.2 : issues with entities on xslt:transform

I'm having some trouble to transform xml nodes containing entities using xslt:transform() with BaseX :
let $xsl := doc('xsl/commun.xsl')
return
xslt:transform(<node>ééé</node>, $xsl)
gives
[FODC0002] "" (Line 1): L'entité "eacute" était référencée, mais pas déclarée.
I have created my database with/without intparse and/or DTD options, with no changes (options basex).
xslt:processor() and xslt:version tell that I'm using java 1.0 as processor.
Here is the declaration of my xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" exclude-result-prefixes="#all"/>xslt:transform
<xsl:template match="/"/>
I don't know what I am doing wrong... Should I declare any entity I want to use in the XSL file?
xslt:processor() and xslt:version tell that I'm using JAVA 1.0 as processor.
As explained here "XSLT 3.0 will be enabled if Version 9.x of the Saxon XSLT Processor (saxon9he.jar, saxon9pe.jar, saxon9ee.jar) is found in the classpath"
Just has to add saxon9he.jar in {Basex Folder}/lib/custom and that's fine
Hope that help

How to disable specific rule in FSharpLint?

I created Settings.FSharpLint and I want to suppress IdentifiersMustNotContainUnderscores rule
Is it possible to disable only one rule?
Example (Doesn't work):
<?xml version="1.0" encoding="utf-8"?>
<FSharpLintSettings>
<Analysers>
<NameConventions>
<IdentifiersMustNotContainUnderscores>
<Enabled>False</Enabled>
</IdentifiersMustNotContainUnderscores>
</NameConventions>
</Analysers>
</FSharpLintSettings>
I tried this and it worked well (But it's for all NameConventions rules):
<?xml version="1.0" encoding="utf-8"?>
<FSharpLintSettings>
<Analysers>
<NameConventions>
<Enabled>False</Enabled>
</NameConventions>
</Analysers>
</FSharpLintSettings>
The IdentifiersMustNotContainUnderscores element needs to be nested inside a Rules element, try:
<?xml version="1.0" encoding="utf-8"?>
<FSharpLintSettings>
<Analysers>
<NameConventions>
<Rules>
<IdentifiersMustNotContainUnderscores>
<Enabled>False</Enabled>
</IdentifiersMustNotContainUnderscores>
</Rules>
</NameConventions>
</Analysers>
</FSharpLintSettings>

how to test a data source-based and websphere application using JUnit and IBM Rational Application Developer?

I have a package of many JAX-WS web services that run in WebSphere 7 where I had configured a data-source to a DB2 database including the JAAS authentication under an alias.
Now, i just want to test the logic of my DAOs, where -of course- I have an entity manager. So, I created an application client project, partially guided by this tutorial http://www.ibm.com/developerworks/rational/library/08/0219_jadhav/, where I have :
an application-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<application-client version="5"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_5.xsd" metadata-complete="false">
<display-name>ServiciosAcademicoTests</display-name>
<resource-ref>
<res-ref-name>ServiciosAcademicoTests</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
a ibm-application-client-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<application-client-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-client-bnd_1_0.xsd" version="1.0">
<resource-ref name="ServiciosAcademicoTests" binding-name="java:comp/env/jdbc/MyDB">
</resource-ref>
</application-client-bnd>
When I run my test, it returns the following error "Null userid is not supported." :
<openjpa-1.2.1- (...) fatal general error> org.apache.openjpa.persistence.PersistenceException: **Null userid is not supported.** ERRORCODE=-4461
I tried specifying and authentication in the ibm-application-client-bnd.xml but I'm still getting the same error :
<?xml version="1.0" encoding="UTF-8"?>
<application-client-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-client-bnd_1_0.xsd"
version="1.0">
<resource-ref name="ServiciosAcademicoTests" binding-name="java:comp/env/jdbc/MyDB">
<authentication-alias name="dmfloresNode01/XXX "/>
</resource-ref>
Just in case, my unit test is this :
public class CursosTest extends TestCase {
ICursoDAO cursoDAO; // From another project
Integer idAlumno = 123456;
String usuarioPortal = "xxx";
public void testCursosLlevados() throws Exception {
cursoDAO = new CursoDAO();
List<CursoLlevadoVO> lstCursos = cursoDAO
.obtenerCursosLlevadosPorAlumno(idAlumno, usuarioPortal);
if (lstCursos != null) {
for (CursoLlevadoVO cursoLlevadoVO : lstCursos) {
System.out.println(cursoLlevadoVO.getNombre());
}
}
assertNotNull(lstCursos);
}
}
I detected that the problem happen when the entitymanager is created :
entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
entityManager = entityManagerFactory.createEntityManager(); // <-- here
Could you help me, please ? two days looking for a solution :( .
UPDATE :
I think that my application-client even isn't querying the data source, because I changed the jdbc/MyDB to jdbc/XXX and the problem is the same (http://www-01.ibm.com/support/docview.wss?uid=swg21596108 , I'm not getting the "Could not lookup datasource named" message but it could be a cause). Also I tried to deactivate the authentication to the data source in the administrative console of Websphere, but I'm getting same results.
This is my persistence.xml file on the project of webservices (that runs fine, the problem is my application-client that is using a DAO class just for testing purposes, not for testing webservice just in case) :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="ServiciosAcademico">
<jta-data-source>jdbc/MyDB</jta-data-source>
<class>...</class>
<properties>
<property name="openjpa.jdbc.Schema" value="XXX"/>
</properties>
</persistence-unit>
. This is my data source on websphere, it's under a certain scope :
Day 3 :
Probably, when I remove the alias for the data source I get the same message, so the application-client could be ok about connecting to the data source, but this isn't using any authorization method.
Thanks for your help. I'm a novice of WebSphere.

apigee policy error - java.lang.String cannot be cast to com.apigee.flow.message.Message

I am trying to transform a JSON response from a target end point into soap message. I have 2 policies in the post flow.
JSONTOXML - If I disable xsltransform I see the xml result so this work.
xsltransform - this just point to my xsltransform file which has the template and dynamic content supposed to come from the xml from step 1.
Both source and output are set to "response" but it looks like it failed to cast in step 2. What should I make step 2 to pick up the xml and apply the xsl? How else can I do this? Thanks
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONToXML async="false" continueOnError="false" enabled="true" name="jsontoxml-2">
<DisplayName>JSONtoXML-2</DisplayName>
<FaultRules/>
<Properties/>
<Options>
<NullValue>NULL</NullValue>
<NamespaceBlockName>#namespaces</NamespaceBlockName>
<DefaultNamespaceNodeName>$default</DefaultNamespaceNodeName>
<NamespaceSeparator>:</NamespaceSeparator>
<TextNodeName>#text</TextNodeName>
<AttributeBlockName>#attrs</AttributeBlockName>
<AttributePrefix>#</AttributePrefix>
<InvalidCharsReplacement>_</InvalidCharsReplacement>
<ObjectRootElementName>Root</ObjectRootElementName>
<ArrayRootElementName>Array</ArrayRootElementName>
<ArrayItemElementName>Item</ArrayItemElementName>
</Options>
<OutputVariable>response</OutputVariable>
<Source>response</Source>
</JSONToXML>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xsltransform-1">
<DisplayName>XSLTransform-1</DisplayName>
<FaultRules/>
<Properties/>
<Source>response</Source>
<ResourceURL>xsl://xsltransform-1</ResourceURL>
<Parameters ignoreUnresolvedVariables="true"/>
<OutputVariable>response</OutputVariable>
</XSL>
OutputVariable cannot be set to 'response'.
Try removing the 'OutputVariable' line, or leaving it empty. Removing it, should cause the output to go to the response payload.
In other words, try this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xsltransform-1">
<DisplayName>XSLTransform-1</DisplayName>
<FaultRules/>
<Properties/>
<Source>response</Source>
<ResourceURL>xsl://xsltransform-1</ResourceURL>
<Parameters ignoreUnresolvedVariables="true"/>
</XSL>
Is this always the case? Can OutputVariable never be set on response?

Removing specific element from xml using sax with xerces library in c++

My problem is that I want to remove lastfiles and all it's child element using sax with the API of Xerces in c++ language??
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE config>
<config datecreated="20011210">
<user>
John Smith
</user>
<login>jsmith</login>
<password>topsecret</password>
<lastfiles>
<lastfile timestamp="20011210T1002">accounts.txt</lastfile>
<lastfile timestamp="20011190T1132">/home/jsmith/docs/letter.doc</lastfile>
</lastfiles>
</config>