Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Doclet and special character

13 views
Skip to first unread message

Pidi

unread,
Apr 13, 2012, 5:21:13 AM4/13/12
to
I'm using the doclet API
(http://docs.oracle.com/javase/1.4.2/docs/tooldocs/javadoc/doclet/)
to create an xml file from my java source code.

I have to print a string like "Set<Float>" in the xml.

If I do: String s = "Set<Float>", in the xml file results: "Set".
If I do: String s = "Set&lt;Float&gt;", in the xml file results:
"Set&amp;lt;Float&amp;gt;"

How could I escape the characted '<' or '&'??

Thank you so much

Roedy Green

unread,
Apr 13, 2012, 5:42:51 AM4/13/12
to
On Fri, 13 Apr 2012 11:21:13 +0200, Pidi <la...@mail.com> wrote,
quoted or indirectly quoted someone who said :

>I have to print a string like "Set<Float>" in the xml.
>
>If I do: String s = "Set<Float>", in the xml file results: "Set".
>If I do: String s = "Set&lt;Float&gt;", in the xml file results:
>"Set&amp;lt;Float&amp;gt;"
>
>How could I escape the characted '<' or '&'??

Where are these &amp; coming from?

1. doclet processor
2. when you go to print the XML

Have you looked at the generated XML to see if the &amp;s are there?

As a kludge you might conside generating Set{Float} then later
converting.

When you feed your Strings in your custom doclet processor, see if
there are alternate add methods that treat the string with different
degrees of literalness.

see http://mindprod.com/jgloss/xml.html#AWKWARD

you can also resort to the CDATA sandwich.

--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..

Pidi

unread,
Apr 13, 2012, 8:48:23 AM4/13/12
to
Il 13/04/2012 11:42, Roedy Green ha scritto:
> On Fri, 13 Apr 2012 11:21:13 +0200, Pidi<la...@mail.com> wrote,
> quoted or indirectly quoted someone who said :
>
>> I have to print a string like "Set<Float>" in the xml.
>>
>> If I do: String s = "Set<Float>", in the xml file results: "Set".
>> If I do: String s = "Set&lt;Float&gt;", in the xml file results:
>> "Set&amp;lt;Float&amp;gt;"
>>
>> How could I escape the characted '<' or'&'??
>
> Where are these&amp; coming from?
>
> 1. doclet processor
> 2. when you go to print the XML

I think it comes from the doclet processor
>
> Have you looked at the generated XML to see if the&amp;s are there?
>
> As a kludge you might conside generating Set{Float} then later
> converting.

Exactly where I have to convert it?

> When you feed your Strings in your custom doclet processor, see if
> there are alternate add methods that treat the string with different
> degrees of literalness.
>
> see http://mindprod.com/jgloss/xml.html#AWKWARD
>
> you can also resort to the CDATA sandwich.

I can't neither use the CDATA because the characters '<' and '>' is not
considered during the doclet processing

Steven Simpson

unread,
Apr 13, 2012, 9:37:33 AM4/13/12
to
On 13/04/12 10:21, Pidi wrote:
> I'm using the doclet API
> (http://docs.oracle.com/javase/1.4.2/docs/tooldocs/javadoc/doclet/)
> to create an xml file from my java source code.

To clarify - you mean you're writing your own doclet?

(What's wrong with
<http://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/index.html>?)

> I have to print a string like "Set<Float>" in the xml.
>
> If I do: String s = "Set<Float>", in the xml file results: "Set".
> If I do: String s = "Set&lt;Float&gt;", in the xml file results:
> "Set&amp;lt;Float&amp;gt;"

Something appears to escaping '&' but not '<' or '>', perhaps.

> How could I escape the characted '<' or '&'??

What technique are you using the generate the XML? Are you using
packages from org.w3c.dom, or just writing to an OutputStream or
Writer? Show us the code - what do you do with 's'?

--
ss at comp dot lancs dot ac dot uk

markspace

unread,
Apr 13, 2012, 10:47:53 AM4/13/12
to
Could you give an example how you are trying to do this? Are you
"printing" the string via a Javadoc tag, or something else?

/**
* @return The value Set<Float> something something.
*/

Or ... ?


Pidi

unread,
Apr 13, 2012, 7:33:15 PM4/13/12
to
Il 13/04/12 15:37, Steven Simpson ha scritto:
> On 13/04/12 10:21, Pidi wrote:
>> I'm using the doclet API
>> (http://docs.oracle.com/javase/1.4.2/docs/tooldocs/javadoc/doclet/)
>> to create an xml file from my java source code.
>
> To clarify - you mean you're writing your own doclet?

Yes

>
> (What's wrong with
> <http://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/index.html>?)
>
>> I have to print a string like "Set<Float>" in the xml.
>>
>> If I do: String s = "Set<Float>", in the xml file results: "Set".
>> If I do: String s = "Set&lt;Float&gt;", in the xml file results:
>> "Set&amp;lt;Float&amp;gt;"
>
> Something appears to escaping '&' but not '<' or '>', perhaps.
>
>> How could I escape the characted '<' or '&'??
>
> What technique are you using the generate the XML? Are you using
> packages from org.w3c.dom, or just writing to an OutputStream or Writer?
> Show us the code - what do you do with 's'?

I'm using org.w3c.dom

Pidi

unread,
Apr 13, 2012, 7:35:56 PM4/13/12
to
Il 13/04/12 16:47, markspace ha scritto:
I take the field type and i "print" it.

So a row like: private Set<Float> numbers;
must print Set<Float>.

markspace

unread,
Apr 13, 2012, 8:20:37 PM4/13/12
to
On 4/13/2012 4:35 PM, Pidi wrote:

> I take the field type and i "print" it.
>
> So a row like: private Set<Float> numbers;
> must print Set<Float>.


That's about as far from an example as humanly possible. I'm looking
for an SSCCE. Short, Self-contained Compilable Example.

http://sscce.org/

I've got something here working, but I don't think it is going to match
your use case. I suspect it in the output of your program, and has
nothing to do with the com.sun.javadoc package.

I'll take a poke at org.w3c.dom, but an example would help. You're the
one asking for help, so I would think it in your best interest to
provide the example.



Lew

unread,
Apr 14, 2012, 3:49:49 PM4/14/12
to
Pidi wrote:
> markspace ha scritto:
>> Pidi wrote:
>>> I'm using the doclet API
>>> (http://docs.oracle.com/javase/1.4.2/docs/tooldocs/javadoc/doclet/)
>>> to create an xml file from my java source code.
>>>
>>> I have to print a string like "Set<Float>" in the xml.
>>>
>>> If I do: String s = "Set<Float>", in the xml file results: "Set".
>>> If I do: String s = "Set&lt;Float&gt;", in the xml file results:
>>> "Set&amp;lt;Float&amp;gt;"
>>>
>>> How could I escape the characted '<' or '&'??
>>
>>
>> Could you give an example how you are trying to do this? Are you
>> "printing" the string via a Javadoc tag, or something else?
>>
>> /**
>> * @return The value Set<Float> something something.
>> */
>>
>> Or ... ?
>>
>
> I take the field type and i [sic] "print" it.

What does "print" (in quotes, no less) mean?

Show us the code.

> So a row like: private Set<Float> numbers;
> must print Set<Float>.

That's a "row"? How is that a "row"?

What does "print" mean, here?

Show us the code.

--
Lew
0 new messages