| Author |
how to restrict strings with particular characters in XML file
|
Srinivas Rallapalli
Greenhorn
Joined: May 20, 2003
Posts: 18
|
|
Suppose i have an XML file, it contains some strings, now i have to write an xsl file to display the strings. there are some constraints to display the strings. 1. it should not display the strings with some special characters like +,/,=, etc. 2. it should display strings only with characters and _ . 3. if it having any other special characters it should display only ?. please help me. How can we validate it? suppose this is the xml file, here it should display only srinir and ramesh_l <?xml version="1.0" encoding="UTF-8"?> <emp> <name>srini r</name> <name>ralla+ srinu</name> <name>(rama)</name> <name>srinir</name> <name>ramesh_l</name> </emp> please help me. thanks in advance. srini.
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
quick.....dirty.....not-verified.....proposal: <xsl:for select = ...> <xsl:choose> <xsl:when test = "contains(./name, '+') || contains(./name, '(') || contains(./name, ' ') || contains(./name, '=') "> <!-- Do not display --> </xsl:when> <xsl therwise> <!-- Display the name --> </xsl therwise> </xsl:choose> I think your choices are using the substring, substring-before, substring-after, contains and the translate functions. Personally, I would prefer the "application using" this XML to do the validation. I don't prefer a lot of validation in XSL. Hope you get the idea, I agree this is by no means a solution. regds.  - madhav [ November 28, 2003: Message edited by: Madhav Lakkapragada ]
|
Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
|
 |
 |
|
|
subject: how to restrict strings with particular characters in XML file
|
|
|