Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Problem is having attributes as a part self closing tag's

Reply
Thread Tools

Problem is having attributes as a part self closing tag's

 
 
Amit
Guest
Posts: n/a
 
      05-21-2007

Hello Everyone,

This is the code I am using..

<xsl:variable name="var_Temp">
<xsl:value-of select="../ParentNode/ChildNode/Node"/>
</xsl:variable>

<xsl:element name="MyNode">
<xsl:attribute name="attr1">
<xsl:text>attr1 value</xsl:text>
</xsl:attribute>
<xsl:attribute name="attr2">
<xsl:value-of select="$var_Temp"/>
</xsl:attribute>
</xsl:element>

Using the above code I get an output looking like

<MyNode attr1="attr1 value" attr2="Some Value">
</MyNode >

But I need the output to look like this, basically i don't want the
ending tag.

<MyNode attr1="attr1 value" attr2="Some Value" />

It would be real nice, if someone can suggest me some alternatives for
this.

Regards
- Amit Gupta

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      05-21-2007
Amit wrote:

> <xsl:variable name="var_Temp">
> <xsl:value-of select="../ParentNode/ChildNode/Node"/>
> </xsl:variable>
>
> <xsl:element name="MyNode">
> <xsl:attribute name="attr1">
> <xsl:text>attr1 value</xsl:text>
> </xsl:attribute>
> <xsl:attribute name="attr2">
> <xsl:value-of select="$var_Temp"/>
> </xsl:attribute>
> </xsl:element>
>
> Using the above code I get an output looking like
>
> <MyNode attr1="attr1 value" attr2="Some Value">
> </MyNode >
>
> But I need the output to look like this, basically i don't want the
> ending tag.
>
> <MyNode attr1="attr1 value" attr2="Some Value" />


You should get
<MyNode attr1="attr1 value" attr2="Some Value"></MyNode>
but certainly not white space between the start tag and end tag.
As for
<MyNode attr1="attr1 value" attr2="Some Value" />
or
<MyNode attr1="attr1 value" attr2="Some Value"/>
that is the same as
<MyNode attr1="attr1 value" attr2="Some Value"></MyNode>
so it should not matter.

Which XSLT processor are you using that inserts the white space?




--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Amit
Guest
Posts: n/a
 
      05-21-2007
> You should get
> <MyNode attr1="attr1 value" attr2="Some Value"></MyNode>
> but certainly not white space between the start tag and end tag.
> As for
> <MyNode attr1="attr1 value" attr2="Some Value" />
> or
> <MyNode attr1="attr1 value" attr2="Some Value"/>
> that is the same as
> <MyNode attr1="attr1 value" attr2="Some Value"></MyNode>
> so it should not matter.
>
> Which XSLT processor are you using that inserts the white space?
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


Hello Martin,

My Problem is not on white spaces, the problem is ending tag.

I know <MyNode attr1="attr1 value" attr2="Some Value"></MyNode> and
<MyNode attr1="attr1 value" attr2="Some Value"/> is equivalent.

but the third party application which is going to import the xml,
doesn't understand this.
For successful import, there should not be any ending xml tag.

Regards
- Amit Gupta

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      05-21-2007
Amit wrote:

> I know <MyNode attr1="attr1 value" attr2="Some Value"></MyNode> and
> <MyNode attr1="attr1 value" attr2="Some Value"/> is equivalent.
>
> but the third party application which is going to import the xml,
> doesn't understand this.
> For successful import, there should not be any ending xml tag.


Which XSLT processor do you use? Check whether it supports any settings
to enforce serializing empty elements as <element-name/>, that is your
only chance.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      05-21-2007
In article <(E-Mail Removed) om>,
Amit <(E-Mail Removed)> wrote:

>I know <MyNode attr1="attr1 value" attr2="Some Value"></MyNode> and
><MyNode attr1="attr1 value" attr2="Some Value"/> is equivalent.


>but the third party application which is going to import the xml,
>doesn't understand this.


Then get a different application! XML is supposed to be a standard.
Programs that accept odd subsets of XML should be rejected.

I realise that you may not find this helpful, but I really don't want
to encourage the people who write such programs. I want their
products to fail.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
Jim Garrison
Guest
Posts: n/a
 
      05-21-2007
Richard Tobin wrote:
> In article <(E-Mail Removed) om>,
> Amit <(E-Mail Removed)> wrote:
>
>> I know <MyNode attr1="attr1 value" attr2="Some Value"></MyNode> and
>> <MyNode attr1="attr1 value" attr2="Some Value"/> is equivalent.

>
>> but the third party application which is going to import the xml,
>> doesn't understand this.

>
> Then get a different application! XML is supposed to be a standard.
> Programs that accept odd subsets of XML should be rejected.
>
> I realise that you may not find this helpful, but I really don't want
> to encourage the people who write such programs. I want their
> products to fail.


In other words, the two forms

<tag attrs.../>

and

<tag attrs...></tag>

are equivalent in standard XML and must be interpreted the same
by any standard XML processor. If the application that processes
this makes a distinction between the two forms, then it is
requiring non-standard XML, and is incorrect. You should
file a bug report with the provider of that application.

Are you absolutely SURE the ending tag is the problem?
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      05-21-2007
Amit wrote:
>> You should get
>> <MyNode attr1="attr1 value" attr2="Some Value"></MyNode>
>> but certainly not white space between the start tag and end tag.
>> As for
>> <MyNode attr1="attr1 value" attr2="Some Value" />
>> or
>> <MyNode attr1="attr1 value" attr2="Some Value"/>
>> that is the same as
>> <MyNode attr1="attr1 value" attr2="Some Value"></MyNode>
>> so it should not matter.
>>
>> Which XSLT processor are you using that inserts the white space?
>>
>> --
>>
>> Martin Honnen
>> http://JavaScript.FAQTs.com/

>
> Hello Martin,
>
> My Problem is not on white spaces, the problem is ending tag.
>
> I know <MyNode attr1="attr1 value" attr2="Some Value"></MyNode> and
> <MyNode attr1="attr1 value" attr2="Some Value"/> is equivalent.
>
> but the third party application which is going to import the xml,
> doesn't understand this.


Then the third-party application is broken and must be replaced.

If you continue to use broken software, you will eventually get broken
data. Replacing the software with something that works properly is much
cheaper than trying to mend the broken data (and the broken decisions
that were made using it).

> For successful import, there should not be any ending xml tag.


As a temporary solution, pass the output through a stream filter to
delete the unwanted end-tags and change the preceding > with />

///Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem is having attributes as a part self closing tag's Amit XML 1 05-24-2007 05:00 PM
__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y;self.z=z boilerplate code) falcon Python 0 07-31-2005 05:41 PM
Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y;self.z=z boilerplate code) Ralf W. Grosse-Kunstleve Python 2 07-12-2005 03:20 AM
Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code Ralf W. Grosse-Kunstleve Python 16 07-11-2005 09:28 PM
__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y;self.z=z boilerplate code) Ralf W. Grosse-Kunstleve Python 18 07-11-2005 04:01 PM



Advertisments