Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Creating solo tags (i.e. <tag .../>) with WST XML api
Creating solo tags (i.e. <tag .../>) with WST XML api [message #231843] Mon, 25 May 2009 14:00 Go to next message
Cristian Mising name is currently offline Cristian Mising name
Messages: 74
Registered: July 2009
Member
Hello,

I have an XML file that I process using the WST API (StructuredDocument,
etc). I use XPath for various parsing jobs and I insert nodes via the
standard DOM API (i.e. node.append(document.createElement(...));).

Is there a way to create an Element that will be saved in the xml file
using it's "short" form (i.e. <a_tag attr1=".."/> instead of <a_tag
attr1=".."></a_tag>.

Thanks in advance,
Cristi.
Re: Creating solo tags (i.e. <tag .../>) with WST XML api [message #231864 is a reply to message #231843] Tue, 26 May 2009 10:22 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2250
Registered: July 2009
Senior Member
Cristian wrote:
> I have an XML file that I process using the WST API (StructuredDocument,
> etc). I use XPath for various parsing jobs and I insert nodes via the
> standard DOM API (i.e. node.append(document.createElement(...));).
> Is there a way to create an Element that will be saved in the xml file
> using it's "short" form (i.e. <a_tag attr1=".."/> instead of <a_tag
> attr1=".."></a_tag>.

Only by using IDOMElement.setEmptyTag(true) before inserting it into
the Document. I don't know of a DOM API way of controlling it
before you transform it into a stream, and even then it's a
transformer-specific parameter.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Creating solo tags (i.e. <tag .../>) with WST XML api [message #231893 is a reply to message #231864] Tue, 26 May 2009 16:34 Go to previous messageGo to next message
Eclipse User
Originally posted by: dcarver.starstandard.org

This isn't a DOM issue, it's a serialization issue. So this is
something as Nintin says has to be handled by the IDOMElement extension
to the w3c.org.Element interface.

In general, if you don't have a Text node or another Child Node, then
most serializers will serialize it out as <tag/>, otherwise they may
serialize it as <tag></tag>, depending on the serializer.

Dave

Nitin Dahyabhai wrote:
> Cristian wrote:
>> I have an XML file that I process using the WST API
>> (StructuredDocument, etc). I use XPath for various parsing jobs and I
>> insert nodes via the standard DOM API (i.e.
>> node.append(document.createElement(...));).
>> Is there a way to create an Element that will be saved in the xml file
>> using it's "short" form (i.e. <a_tag attr1=".."/> instead of <a_tag
>> attr1=".."></a_tag>.
>
> Only by using IDOMElement.setEmptyTag(true) before inserting it into the
> Document. I don't know of a DOM API way of controlling it before you
> transform it into a stream, and even then it's a transformer-specific
> parameter.
>
Re: Creating solo tags (i.e. <tag .../>) with WST XML api [message #231909 is a reply to message #231893] Wed, 27 May 2009 06:27 Go to previous message
Cristian Mising name is currently offline Cristian Mising name
Messages: 74
Registered: July 2009
Member
Dear Nitin,
>> Only by using IDOMElement.setEmptyTag(true) before inserting it into the
>> Document. I don't know of a DOM API way of controlling it before you
>> transform it into a stream, and even then it's a transformer-specific
>> parameter.

It worked. Thanks a lot!

Dear David,

> In general, if you don't have a Text node or another Child Node, then
> most serializers will serialize it out as <tag/>, otherwise they may
> serialize it as <tag></tag>, depending on the serializer.

This is not the case of the WST serializer.

Best regards and thanks again for your answers.
Cristi.
Previous Topic:CSS displaying in JavaDoc
Next Topic:runtimePath variable in Component Core
Goto Forum:
  


Current Time: Thu Aug 21 06:18:51 EDT 2014

Powered by FUDForum. Page generated in 0.02061 seconds