aspose file tools
The moose likes XML and Related Technologies and the fly likes how to restrict strings with particular characters in XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "how to restrict strings with particular characters in XML file " Watch "how to restrict strings with particular characters in XML file " New topic
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>
<xsltherwise>
<!-- Display the name -->
</xsltherwise>
</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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to restrict strings with particular characters in XML file
 
Similar Threads
how to know the name of the next element
finding max string length if more than 2 elements are having same length.
Need Parser program to write elements into xml file..!
displaying the string before a special character
finding max string length if more than 2 elements are having same length.