Steve Kritzler

Greenhorn
+ Follow
since Apr 14, 2005
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 Steve Kritzler

Hello,

I'm encountering a small problem with my app that I'm hoping someone can clear up for me. I am doing a two-step marshalling procedure to create an XML file. What happens is all < and > characters from the first marshall step are converted to & lt; and & gt; during the second marshall step. (I've added a space after the escape character)

Here's a little preamble and some examples of the steps involved: I'm using JAXB to unmarshall an XML file into a collection of objects - each object is an input txn. I iterate the collection and process the txns.

Here is an example of one of the input txns:
<inputTxn>
<field1>xxx</field1>
<field2>xxx</field2>
...
</inputTxn>

For each unmarshalled txn (object), we marshall it to string data. This is done to "preserve" the originating txn in the format as received (XML format). This part works fine, the resulting string data looks like the received XML txn above.

We then go on to build a txResult object, and one of the attributes for this object is the originalTxn (the marshalled-txn as string data). We populate the remaining attributes of the txResult object (transaction Ids, error information etc), and then marshall the txResult object.

So, to clarify, txResult contains an atribute called originalTxn which is a String and has a value of "<inputTxn><field1>xxx</field1>...</inputTxn>"

This is what I'm expecting the marshalled txResult object to look like:
<txResult>
<transactionId>12345</transactionId>
<errors>none</errors>
<originalTxn>
<inputTxn>...</inputTxn>
</originalTxn>
</txResult>

But what I get is:
<txResult>
<transactionId>12345</transactionId>
<errors>none</errors>
<originalTxn>
& lt;inputTxn& gt;...& lt;inputTxn& gt;
</originalTxn>
</txResult>

Why are the < and > characters in the originalTxn attribute converted to & gt; and & lt; during the 2nd marshall phase, and what can I do to prevent that from occurring?

Very sorry for possibly asking an extremely stupid question, but I'm not sure what the cause of this is and it's pretty darn frustrating. Thanks for your time and assistance, always much appreciated....

Steve

[ July 19, 2005: Message edited by: Steve Kritzler ]
[ July 19, 2005: Message edited by: Steve Kritzler ]
Thanks again Hari.....

Awesome....not quite, but it's gotten me a LOT closer to where I want to be and I'm very ok with that.

I understand what you're doing with that last code snippet, and I believe I can work with that to get past my little headache.

So, thanks again very much for your help....take care.
Thanks very much for your reply Hari - much appreciated.

I understand your response. Allow me to explain my reasoning for coding the xs:choice....perhaps I am doing something else wrong here....

I need to represent the group of transactions in my XML file as a collection - eventually I will unmarshall the file and then iterate-and-process the transactions within the collection. During processing, I'm doing an instanceof check to determine if the current tx is of type TxType1 or TxType2 etc.

I can't specify minOccurs/maxOccurs on the <xs:complexType name="TransactionCollection"> line. At the time I thought I needed the xs:choice line so that was a logical spot for the min/maxOccurs elements.

If I have to remove xs:choice, how do I represent the mix of possible transactions as a collection?

Again, sorry for a silly question. This seems so straightforward but I can't get this to work. Thanks again for your time and assistance.
Sorry if there's an obvious answer to this....I've been digging and playing and can't get this to work....

I am having problems enforcing the order of optional fields.

In my schema I've defined a complex type that is composed of other complex types. Not all of the composing types have to be present, but whichever are present must be in a specific order.

For some reason, the schema doesn't enforce the order. I've been reading and playing with different combinations of xs:choice and xs:sequence. Doesn't matter what order the composing types are in my XML file - file is unmarshalled and parsed with no complaints (using JAXB).

How can I enforce the order of the composing types? What am I missing here? Here is a snippet of the schema, I didn't include definitions of the composing types. My XML file contains txType2 followed by txType1 and doesn't complain about the sequence.

<xs:complexType name="TransactionCollection">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jxb roperty name="TransactionCollection"/>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="txType1" type="TxType1" minOccurs="0"/>
<xs:element name="txType2" type="TxType2" minOccurs="0"/>
<xs:element name="txType3" type="TxType3" minOccurs="0"/>
<xs:element name="txType4" type="TxType4" minOccurs="0"/>
<xs:element name="txType5" type="TxType5" minOccurs="0"/>
<xs:element name="txType6" type="TxType6" minOccurs="0"/>
</xs:sequence>
</xs:choice>
</xs:complexType>


Thanks in advance for your time and assistance...
Thanks for the reply. I'm actually trying to accomplish via Query by Example, or alternatively HQL.

At this point it looks like it's an explicit fetch against the collection (only), but it would be nice if I could do it in one query against the parent table.
Hi. I have a one-to-many relationship that I'm trying to build a query on, where I limit the number of rows returned in the collection, not in the entire result set. So for instance, where one dealership has many cars, I want a query that returns all dealerships and only 5 cars for each dealership. Can't get it to work, everything I try applies the "maxrows" to the entire result set.

Anyone have success with this or something similar?

Thanks in advance for your time and assistance...
Hello,

I'm getting the same problem running JAXB to "inflate" the contents of an XML file into objects...

I was wondering how one goes about removing the signature from the jar files, or better still, how to look at the signing of the jars to see how they
re signed and which are different. Sorry if this too high-level a question for this forum.

Thanks for your help...
19 years ago
Awesome, thanks a lot guys...

One small follow-up...I understand the correction where the new string is created on the heap, however isn't a copy also in the literal string pool?

This would be the case if you were explicitly calling the String constructor (right??), so if the call to toUpperCase() returns a reference to a new String object (with a unique value) isn't a copy placed in the pool?

Thanks again for your help...
[ April 22, 2005: Message edited by: Steve K. ]
19 years ago
Hi there, I'm still a little confused about a part of this. Consider:

String s1 = "hello";
String s2 = "hello";
s1.toUpperCase();
if (s1 == s2)
System.out.println("== match");
if (s1.equals(s2))
System.out.println("equals() match");

Running this prints out both "match" messages.

The call on line 3 does not modify the original string (which remains in the literal string pool), however it creates a new string in the pool and updates s1 with a reference to that new string.

So, if s2 is still referencing the object with "hello", and s1 is referencing object with "HELLO", how is it that both tests are satisfied???
[ April 22, 2005: Message edited by: Steve K. ]
19 years ago