XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> - Stylus Studio - Registrar en o... (1)
-> + Stylus Studio - Registrar en o... (2)
-> + Can a pipeline send a file by ... (2)
-> + After Updateing WIN10 to WIN11... (12)
-> + Where do I add the custom java... (3)
-> + Where is the Diagram tab? (5)
-> + Applying XSLT to Word DOCX/XML (2)
-> - CSV conversion via ConvertToXM... (1)
-> + Text symbols in SS not same as... (4)
-> + Exposing xquery as webservice ... (6)
-> + Syntax Identifier (2)
-> + Saving a Converted XML as an X... (5)
-> + Output document cannot be pars... (4)
-> - Archiving output from conversi... (1)
-> + EDIFACT guideline from Stylus ... (3)
-> + CSV file putting all the data ... (5)
-> + Can't install Home version 64b... (5)
-> + presale - Can I covers this sc... (5)
-> + Problem with UNB (5)
-> + Splitting EDIFACT files pipeli... (4)
-- [1-20] [21-40] [41-60] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Posttop
sharath nSubject: filter out hexadecimal characters in a string
Author: sharath n
Date: 22 Jul 2005 06:19 AM
I have an xml file with combination of hexadecimal and ascii characters..
i need an xsl to filter out all the characters other than from List of characters(see below) and replace with '@'

source xml:
<?xml version="1.0"?>
<person>
<name>&h0x12;my name</name>
<age>22</age>
<sex>f</sex>
<location>man&h0x22;chester&h0x31;</location>
<country>uk</country>
</person>

result xml:
<?xml version="1.0"?>
<person>
<name>@my name</name>
<age>22</age>
<sex>f</sex>
<location>man@chester@</location>
<country>uk</country>
</person>

allowed characters stored in any format depending on our convenience.

like..

<AllowedCharacters>
<character id="1">a</character>
<character id="2">b</character>
<character id="3">c</character>
<character id="4">d</character>
<character id="5">e</character>
<character id="6">f</character>
<character id="7">g</character>
<character id="8">h</character>
<character id="9">i</character>
<character id="10">j</character>
<character id="11">k</character>
<character id="12">l</character>
<character id="13">m</character>
<character id="14">n</character>
<character id="15">o</character>
<character id="16">p</character>
<character id="17">q</character>
<character id="18">r</character>
<character id="19">s</character>
<character id="20">t</character>
<character id="21">u</character>
<character id="22">v</character>
<character id="23">w</character>
<character id="24">x</character>
<character id="25">y</character>
<character id="26">z</character>
<character id="24">x</character>
<character id="27">1</character>
<character id="28">2</character>

<!-- all the allowed characters are added here -->
..
...
....
</AllowedCharacters>


one can use combination of javascript and xsl.

i think xsl looks end XSL looks like

----------------------------------------------

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:sg="http://xml.myname.com/mynamespace"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>

<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="text()">
<xsl:value-of select="."/> <!-- here we have to filter out hexadecimal characters -->
</xsl:template>

</xsl:stylesheet>
-------------------------------------------------



Thanks for your reply
mike

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.