tags:

views:

50

answers:

2

I want design something like...

<DB[0]><xsl:value-of select="test"><DB[0]>

which will update the database table field DB[0] with data test. But it's not working ...as xsl is not allowing [] bracket.

+1  A: 

XML element Naming Conventions

  • Names can contain any alphanumeric character, but must not start with a number or punctuation character.
  • Names cannot contain spaces.
  • Names must not start with the letters xml, as they could be easily confused with an XML document definition.
  • Do not use ":" characters within element names.

For exact definition, please visit here.

So either '[' or ']' is not allowed.

Lalith
A: 
  1. In case you need to create a well-formed XML document, then a string like "<DB[0]>" isn't a legal name.

  2. In case you want to create just text, you can alwyas do so by specifying:

<xsl:output method="text"/>

So, this transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
 <xsl:output method="text"/>

 <xsl:template match="/">
   &lt;DB[0]><xsl:value-of select="test"/>&lt;/DB[0]>
 </xsl:template>
</xsl:stylesheet>

when applied on this XML document:

<test>XXX</test>

produces:

<DB[0]>XXX</DB[0]>
Dimitre Novatchev
I want XML document and not text. is there any way to do <DB"0">xxx</DB"0"> and then replace DB"0" with DB[0] ?
Manoj
@Manoj: No, neither `<DB"0">xxx</DB"0">` nor `<DB[0]>XXX</DB[0]>` is wellformed XML. I'd say both of them don't have even close similarity to XML. A name in XML cannot contain the `[` or the `]` character.
Dimitre Novatchev