Brian Grey

Ranch Hand
+ Follow
since Nov 15, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brian Grey

I have to "sort" an XML using the following XSL. This XSL gets rid of the node characteristic of type SETTINGSET.


I was thinking to use xsl:sort. I found examples using values but none using nodes as criteria.

I have to move up the parm element just before the node characteristic.


current XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[not(@type='SETTINGSET')]"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>



actual XML

<characteristic type="PXLOGICAL">
<characteristic type="PORT">
<parm name="PORTNBR" value="8080"/>
</characteristic>
<characteristic type="PXPHYSICAL">
<parm name="PXADDR" value="131.111.3.4"/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>
</characteristic>


<parm name="PROXY-ID" value="PROXY1"/>
<parm name="NAME" value="Proxy 1"/>


</characteristic>



Expected XML:

<characteristic type="PXLOGICAL">

<parm name="PROXY-ID" value="PROXY1"/>
<parm name="NAME" value="Proxy 1"/>

<characteristic type="PORT">
<parm name="PORTNBR" value="8080"/>
</characteristic>

<characteristic type="PXPHYSICAL">
<parm name="PXADDR" value="131.111.3.4"/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>
</characteristic>

</characteristic>

Edit Comment: Disabled smiles in the post.
[ April 02, 2005: Message edited by: Madhav Lakkapragada ]
I need to add the attribute "version" in the wap-provisioningdoc node. How can I do this using the following XSL? This XSL gets rid of the node characteristic of type SETTINGSET.

current XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[not(@type='SETTINGSET')]"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>



Input XML
<wap-provisioningdoc>
<characteristic type="SETTINGSET">
<parm name="NAME" value="NOKIA-6170"/>
<parm name="STATE" value="2"/>
<parm name="SERVICE" value="WAPGPRS"/>
</characteristic>
<characteristic type="PXLOGICAL">
<parm name="TRUST"/>
<parm name="MASTER"/>
<parm name="STARTPAGE" value="http://www.bank.com/startpage.wml"/>
</characteristic>
<characteristic type="NAPDEF1">
<parm name="INTERNET"/>
</characteristic>
<characteristic type="APPLICATION">
<characteristic type="RESOURCE">
<parm name="STARTPAGE"/>
</characteristic>
</characteristic>
<characteristic type="ACCESS">
<parm name="RULE"/>
</characteristic>
</wap-provisioningdoc>


Result expected:
<wap-provisioningdoc version="1.0">
<characteristic type="PXLOGICAL">
<parm name="TRUST"/>
<parm name="MASTER"/>
<parm name="STARTPAGE" value="http://www.bank.com/startpage.wml"/>
</characteristic>
<characteristic type="NAPDEF1">
<parm name="INTERNET"/>
</characteristic>
<characteristic type="APPLICATION">
<characteristic type="RESOURCE">
<parm name="STARTPAGE"/>
</characteristic>
</characteristic>
<characteristic type="ACCESS">
<parm name="RULE"/>
</characteristic>
</wap-provisioningdoc>


Thanks
How can I remove the DOCTYPE line from the xml? When I leave this line, I get an exception.

Exception if DOCTYPE line exists:
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:521)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:498)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:626)
at java.net.URL.openStream(URL.java:913)
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:796)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:756)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:267)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:826)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:524)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580)



XML file uesd
<?xml version="1.0"?>
<!DOCTYPE wap-provisioningdoc PUBLIC "-//WAPFORUM//DTD PROV 1.0//EN" "http://www.wapforum.org/DTD/prov.dtd">
<wap-provisioningdoc version="1.0">
....





DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
Document doc = factory.newDocumentBuilder().parse(new File("Test2.xml"));

TransformerFactory tFactory = TransformerFactory.newInstance();

Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("mylib.xsl"));

Source source = new DOMSource(doc);
Result result = new StreamResult(new FileOutputStream("Test3.xml"));

transformer.transform(source, result);
I found my mistake. The command [not(@type='NAPDEF')] was in the wrong place.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[not(@type='NAPDEF')]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
XML FILE:
<wap-provisioningdoc version="1.0">
<characteristic type="BOOTSTRAP">
<parm name="PROVURL" value="http://55555"/>
</characteristic>
<characteristic type="PXLOGICAL">
<parm name="PROXY-ID" value="PROXY1"/>
<parm name="NAME" value="Proxy 1"/>
<parm name="STARTPAGE" value="Homepage_URL"/>
<characteristic type="PORT">
<parm name="PORTNBR" value="8080"/>
</characteristic>
<characteristic type="PXPHYSICAL">
<parm name="PXADDR" value="131.111.3.4"/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>
</characteristic>
</characteristic>
.....


I'd like to use a XML schema file to perform validation tests. The XML to test is very particular. I will try to give you a clear explanation.

For instance an element characteristic that has an attribute type "PXLOGICAL" can occur 0 or more times. If it exists, the element parm with name "NAME" MUST exist, the others are optional.

How can do this? How can I create different "complexType" and used them depending of the characteristic type?

<xs:complexType name="characteristicType">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="BOOTSTRAP"/> (occur 0 or more)
<xs:enumeration value="PXLOGICAL"/> (occur 0 or more) But if exits, should follow parmTypePXLOGICAL rules
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>


<xs:complexType name="parmTypePXLOGICAL">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="PROXY-ID"/> (the paramater is required)
<xs:enumeration value="NAME"/> (the paramater is required)
<xs:enumeration value="STARTPAGE"/> (occur 0 or 1 time)
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
It's a long time I haven't worked with XSLT/XPath. I'm trying to remove a particular node from an XML.

Here is an example:

<wap-provisioningdoc>
<characteristic type="PXLOGICAL">
<parm name="NAME" value="Prov_NAME"/>
<parm name="PROV-PIN" value="Prov_PIN"/>
<parm name="NAMEPAGE" value="Homepage_NAME"/>
<parm name="STARTPAGE" value="Homepage_URL"/>
</characteristic>
<characteristic type="NAPDEF">
<parm name="NAPID" value="NAP1"/>
<parm name="NAP-ADDRESS" value="Bearer_ACCESSPOINT"/>
</characteristic>
</wap-provisioningdoc>

I'd like to remove the node characteristic that has a type "NAPDEF".

the result should be:

<wap-provisioningdoc>
<characteristic type="PXLOGICAL">
<parm name="NAME" value="Prov_NAME"/>
<parm name="PROV-PIN" value="Prov_PIN"/>
<parm name="NAMEPAGE" value="Homepage_NAME"/>
<parm name="STARTPAGE" value="Homepage_URL"/>
</characteristic>
</wap-provisioningdoc>


So I wrote this:

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*[not(type='NAPDEF')]|node()"/>
</xsl:copy>
</xsl:template>
But it doesn't work. How can I select the nodes that have no characteristic node of type NAPDEF?

[ March 15, 2005: Message edited by: Brian Grey ]
[ March 15, 2005: Message edited by: Brian Grey ]
How can I get the number of rows on a specific table? I'm using Kodo JDO 3.1.5 with Oracle.


I want to know how many rows there are in the table before to execute the final query. I want to do this because when there are 100.000 rows or more I get a java.lang.OutOfMemoryError. So I don't to want to execute the final query if there are too many rows.

protected Collection execute(Class type, String filter) {

final Extent extent = getPersistenceManager().getExtent(type, true);
query = pm.newQuery(extent, filter);
query.setOrdering(orderBy + " " +
(orderAscending ? "ascending" : "decending"));

// TODO
// Get the number of rows
numberOfRows = Xxxxxxxxxxxxx;
if (numberOfRows > MAX_PER_COLLECTION) {
throw new XxxxxxException("Too Many Rows: " + result.size());
}
// TODO

final Collection result = (Collection) query.execute();

if (log.isDebugEnabled()) {
log.debug("Found " + result.size() + " match(es)");
}
return result;
}
Is there a way to count the number of rows using KODO? Is there a special query?
Thks
thanks for the reply

I'm not sure how I'm going to do the "page/querie" because of the impact. The product is going to be delivered next week.

just another question
Is there a project (or kind of library) in sourceforge that deals with the navigation stuff (icon, link, button... next, prevous, next 10 pages...)
19 years ago
Here is my problem:

In my web application deployed on Tomcat, there is a search page that can retrieve all �objects� from an Oracle database. These �objects� are phone cards objects that have properties like phone number, profile, etc�

The client can have 100.000, 200.000 cards or more in the system. Actually when the client wants to see the result of his search, the system displays it in pages with 15 �objects� (or �cards�) per page. On the top of the page there is a direct link of the other pages. So the client can navigate trough all pages using these links or using the previous/next buttons.
The problem is: when the client doesn�t put any criteria into the search page (meaning that he�s going to get all �objects� (= can be 10.000, 100.000 or more)), the system returns �out of memory� after a few long minutes.
The search functionality returns a collection of objects. A �page iterator� splits it into several pages. I think that the collection that contains the result cannot handle it.
By the way, I�m using Kodo as a �persistence manager�.

Here is the method that retrieves all objects from a search (with an empty filter in this case)
protected Collection execute(Class type, String filter) {

final Extent extent = getPersistenceManager().getExtent(type, true);
query = pm.newQuery(extent, filter);
query.setOrdering(orderBy + " " + (orderAscending ? "ascending" : "decending"));

final Collection result = (Collection) query.execute();
return result;
}

Thanks
19 years ago
I'm trying to generate the SQL script using the schema.xml that Kodo generated. The Foreign Keys are still missing in the script. But they exist in the schema.xml.

I put this line inside the kodo.properties but nothing has changed
kodo.jdbc.ForeignKeyConstraints: true


How can I force kodo to generate the Foreign Keys while creating the SQL script?

Thanks


kodo.properties

kodo.LicenseKey=XXXX-XXXX-XXXX-XXXX-XXXX
kodo.ee.ManagedRuntimeProperties=TransactionManagerName=java:/TransactionManager
kodo.Log: DefaultLevel=ERROR

javax.jdo.PersistenceManagerFactoryClass=kodo.jdbc.runtime.JDBCPersistenceManagerFactory
javax.jdo.option.ConnectionDriverName=oracle.jdbc.driver.OracleDriver
javax.jdo.option.ConnectionUserName=USERNAME
javax.jdo.option.ConnectionPassword=PASSWORD
javax.jdo.option.ConnectionURL=jdbc racle:thin:@coyote:1521 EV
javax.jdo.option.Optimistic=true
javax.jdo.option.RetainValues=true
javax.jdo.option.NontransactionalRead=true



build.xml
......
<target name="jdo-copy">
<copy todir="${classes.dir}">
<fileset dir="${java.dir}">
<include name="**/*.jdo"/>
</fileset>
</copy>
</target>
<target name="jdo-enhance" depends="jdo-copy">
<jdoc>
<classpath refid="class.path"/>
<fileset dir="${classes.dir}">
<include name="**/*.jdo"/>
</fileset>
<config propertiesFile="kodo.properties"/>
</jdoc>
<mappingtool action="refresh" schemaFile="${target.dir}/schema.xml">
<classpath refid="tools.class.path"/>
<fileset dir="${classes.dir}">
<include name="**/*.jdo"/>
</fileset>
<config propertiesFile="kodo.properties"/>
</mappingtool>
</target>
<target name="refresh-datastore" depends="jdo-copy">
<schematool action="refresh">
<classpath refid="tools.class.path"/>
<fileset file="${target.dir}/schema.xml"/>
<config propertiesFile="kodo.properties"/>
</schematool>
</target>
<target name="generate-sql" depends="jdo-copy">
<schematool action="dropDB" file="${sql.dir}/oracle/scripts/Kodo-DropTables.sql">
<classpath refid="tools.class.path"/>
<fileset file="${target.dir}/schema.xml"/>
<config propertiesFile="kodo.properties"/>
</schematool>
<schematool action="refresh" file="${sql.dir}/oracle/scripts/Kodo-CreateTables.sql">
<classpath refid="tools.class.path"/>
<fileset file="${target.dir}/schema.xml"/>
<config propertiesFile="kodo.properties"/>
</schematool>
</target>
......


schema.xml

<schemas>
<schema>
......
<table name="SUBCA_JOBSET">
<column name="JOBSET_MSISDN" type="varchar" size="255"/>
<column name="KEY0" type="varchar" size="255"/>
<fk name="F_SBC_BST_JOBSET_REF" to-table="SUBCAMPAIGN" column="KEY0"/>
<fk name="F_SBC_BST_JOBSET_ELEMENT" to-table="JOB" column="JOBSET_MSISDN"/>
<index name="I_SBC_BST_JOBSET" column="KEY0"/>
<index name="I_SBC_BST_JOBSET1" column="JOBSET_MSISDN"/>
</table>
......
</schema>
</schemas>
my mistake... it did a bad copy-paste
everything is perfect now

thanks for your help
19 years ago
Is there a way to specify the extension of a struts action?

Example:
http://127.0.0.1:8080/Card/Provisioning/Create.do

I'd like to change it to

http://127.0.0.1:8080/Card/Provisioning/Create.web


I want to do this because I need to get rid of the security constraint for this action (only this one). This action must be accessible for everyone without going trough the login page (the user should not get the login page if he clicks on this link)

So, I was thinking to solve my problem by adding another security-constraint section into web.xml.

I'm not sure if this could work. Is there a way to tell struts that the action /Card/Provisioning/Create should be /Card/Provisioning/Create.web instead of Create.do ?

Thanks


struts-config.xml:

<action input="/Card/Provisioning/CreationInput.jsp" name="cardForm" path="/Card/Provisioning/Create" scope="request" type="com.gemplus.preview.gui.card.ProvisioningCreateAction" validate="true">
<forward name="forward" path="/Card/Provisioning/CreationResponse.jsp"/>
</action>


web.xml:

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.web</url-pattern>
</servlet-mapping>


<security-constraint>
<web-resource-collection>
<web-resource-name>With auth-constraint</web-resource-name>
<url-pattern>*.do</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>serviceManager</role-name>
<role-name>csr</role-name>
</auth-constraint>
</security-constraint>


<security-constraint>
<web-resource-collection>
<web-resource-name>Without auth-constraint</web-resource-name>
<url-pattern>*.web</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint>
19 years ago
Is it possible do not use the security constraint on a specific page (action form struts) ?
This is the specific page a don't to have any constraint meaning no login page should appear if the user is not login.

/Card/Provisioning/Create.do

How should I modify the web.xml?
<security-constraint>
<web-resource-collection>
<web-resource-name>GemConnect Preview</web-resource-name>
<url-pattern>*.do</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>serviceManager</role-name>
<role-name>csr</role-name>
</auth-constraint>
</security-constraint>
19 years ago
I'm trying to connect to a web application on my local server (tomcat) using the HttpClient from this library commons-httpclient-2.0.2.jar.

I get this message even if I set followRedirects to true (httpMethod.setFollowRedirects(true)

2005/01/19 08:05:08:435 EST [INFO] HttpMethodBase - Redirect requested but followRedirects is disabled
java.lang.InternalError: the HTTP server return an error: 302 (Moved Temporarily)

I have no idea how to solve this problem. I tried to find out on the internet, I got nothing. And does it mean exactly?
19 years ago