[jdom-interest] Question about the "<" Tag

Mattias Jiderhamn mj-lists at expertsystems.se
Tue Mar 4 23:56:29 PST 2008


Another way to put it: What you are trying to produce isn't XML, so you 
shouldn't be using JDOM.

 /Mattias Jiderhamn

Rolf wrote (2008-03-03 13:42):
> Hi Ramo
>
> Technically, you do have the result you want...
>
> '<' is not valid content in attribute values (or in Element text....). 
> See the XML specification here:
>
> http://www.w3.org/TR/2006/REC-xml-20060816/#sec-common-syn
>
> where it indicates:
> [10]       AttValue       ::=       '"' ([^<&"] | Reference)* '"' |  
> "'" ([^<&'] | Reference)* "'"
>
> Basically, the characters < & and " are not allowed in attribute 
> values. The way to get these characters is to use XML 'excapes', or 
> nore formally called Entity Values.
>
> Section http://www.w3.org/TR/2006/REC-xml-20060816/#syntax of the 
> specification shows how to represent the characters < and & in XML 
> with &lt; and &amp; respectively.
>
> When an XML Parser (like SAX used in JDOM) reads the document, it will 
> reverse the escaped values &lt; and &amp; to the original values < and &.
>
> Any other escape sequences in the XML file starting with & and ending 
> with ; will also be replaced with the appropriate values according to 
> Entity value definitions too. There are many other escapes like &quot; 
> and &gt; for " and >
>
> Rolf
>
> Ramo At Skuff wrote:
>> Hi,
>>
>> i try to get somethign like this:
>>
>> xml:
>> <FormElement type="tx" character="text" id="tx_00_user" 
>> name="tx_00_user"
>> tabmember="loguser" mandat="y"  size="20" checkValue="isThisset" >
>>
>>
>> To parse with this line:
>>
>> input.setAttribute("value", "<" + "?pho " +
>> attributes.getValue("checkValue") + " (\"" + 
>> attributes.getValue("name")  +
>> "\"); ?>");
>>                            
>>
>> to get this:
>>
>> <input type="text" id="tx_00_user" name="tx_00_user" class="mandatory"
>> size="20" value<?php isThisset ("tx_00_user"); ?>" />
>>
>> But i get this:
>>
>> <input type="text" id="tx_00_user" name="tx_00_user" class="mandatory"
>> size="20" value="&lt;?php isThisset (&quot;tx_00_user&quot;); ?&gt;" />
>>
>>
>> Is there a way or a trick to get the result i want?
>>
>> Many thanks
>>
>> ramo



More information about the jdom-interest mailing list