473,804 Members | 3,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Maintaining a Great-than Character in an Attribute Value

I want to transform the following xml file
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b attrib="if 3 2">
</b>

<b attrib="3 1">
</b>
</a>

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

into this xml file
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b attrib="3 2">
</b>

<b attrib="3 1">
</b>
</a>

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

i.e. I want to remove the "if" character from the start of the value of
the attribute "attrib"

I am using the style sheet...
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="node( ) | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node( )"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@attrib[starts-with(., 'if ')]">
<xsl:attribut e name="attrib">
<xsl:value-of select="substri ng-after(., 'if ')"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

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

with "Xalan Version Xalan Java 2.4.1", but I get the following output
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b attrib="3 &gt; 2">
</b>

<b attrib="3 &gt; 1">
</b>
</a>

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

where the greater-than character is changed to &gt; .

I need to have the single character in the output also.

Is there any way in XSLT of keeping the greater-than and less-than
characters and < in attribute values when you transform instead of
having &gt; and &lt; ?

If there is no way to achieve this in XSLT, what would be the
recommended method for achieving this?

Any help\pointers greatly appreciated,

Regards,

Metric

Aug 15 '06 #1
14 1728


go************@ yahoo.co.uk wrote:

with "Xalan Version Xalan Java 2.4.1", but I get the following output
<b attrib="3 &gt; 2">
where the greater-than character is changed to &gt; .

I need to have the single character in the output also.
Why, any XML parser/tool should properly unescape the &gt; entity
reference as the '>' character?

If you want '>' then I guess you need to write your own serializer to
serialize the result tree of the XSLT transformation.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 15 '06 #2

go************@ yahoo.co.uk wrote:
where the greater-than character is changed to &gt; .
I need to have the single character in the output also.
Then stop needing that.
http://www.w3.org/TR/2004/REC-xml-20040204/#syntax
The character ">" MAY be encoded as &gt; where you're encountering it.
So it's an error if your XML-consuming application doesn't recognise
that. You should concentrate on fixing that, not working around its
errors. Otherwise these errors build up and you build a non-robust
system.

Aug 15 '06 #3
Is there any way in XSLT of keeping the greater-than and less-than
characters and < in attribute values when you transform instead of
having &gt; and &lt; ?
Not in XSLT by itself, no. Write your own serializer, or (simpler) write
a text-processing-based postprocessor.

Better answer: Don't fix what ain't broke. If your problem is that some
downstream tool cares about this difference, fix that tool.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Aug 15 '06 #4
Thanks for the replies.

I need to keep the great-than character, <, in the attribute value of
the original XML file. So it looks like I will have to use another
approach other than, or in addition to, XSLT.

Thanks.

go************@ yahoo.co.uk wrote:
I want to transform the following xml file
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b attrib="if 3 2">
</b>

<b attrib="3 1">
</b>
</a>

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

into this xml file
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b attrib="3 2">
</b>

<b attrib="3 1">
</b>
</a>

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

i.e. I want to remove the "if" character from the start of the value of
the attribute "attrib"

I am using the style sheet...
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="node( ) | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node( )"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@attrib[starts-with(., 'if ')]">
<xsl:attribut e name="attrib">
<xsl:value-of select="substri ng-after(., 'if ')"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

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

with "Xalan Version Xalan Java 2.4.1", but I get the following output
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b attrib="3 &gt; 2">
</b>

<b attrib="3 &gt; 1">
</b>
</a>

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

where the greater-than character is changed to &gt; .

I need to have the single character in the output also.

Is there any way in XSLT of keeping the greater-than and less-than
characters and < in attribute values when you transform instead of
having &gt; and &lt; ?

If there is no way to achieve this in XSLT, what would be the
recommended method for achieving this?

Any help\pointers greatly appreciated,

Regards,

Metric
Aug 16 '06 #5
go************@ yahoo.co.uk wrote:
I need to keep the great-than character, <, in the attribute value of
the original XML file.
I still say that the right fix is to undo that requirement. Your milage
may vary.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Aug 16 '06 #6
In article <11************ **********@74g2 000cwt.googlegr oups.com>,
<go************ @yahoo.co.ukwro te:
>I need to keep the great-than character, <, in the attribute value of
the original XML file.
(You mean presumably.)

You need to explain *why* you have to keep it. People aren't going to
spend much time helping you to do something they think is pointless.

-- Richard
Aug 16 '06 #7
go************@ yahoo.co.uk wrote:
I need to keep the great-than character, <, in the attribute value of
the original XML file.
Less than or greater than ? The permitted use of each character is
different in XML. A greater than ">" _MAY_ be replaced by the entity
reference, is acceptable as a character, and must always be parseable
by "downstream " tools whether it appears as a character or an entity
reference.

A less than character "<" is right out. That's just not well-formed if
used there. Verboten.
You can still keep XSLT if you produce the output as a DOM and
serialize it to a file yourself. So long as you can guarantee you'll
avoid encoding issues, namespaces and <![CDATA[ sections then it's not
hard to DIY it.

Aug 16 '06 #8
Andy Dingley wrote:
You can still keep XSLT if you produce the output as a DOM and
serialize it to a file yourself. So long as you can guarantee you'll
avoid encoding issues, namespaces and <![CDATA[ sections then it's not
hard to DIY it.
I have both less-than and greater-than characters in the attribute
value of the input file. I need these less-than and greater-than
characters in the output file also.

Will this work even with a less-than character?

Aug 16 '06 #9

go************@ yahoo.co.uk wrote:
Will this work even with a less-than character?
How should I know? That's simply not XML. You do that, you're out on
your own.

Aug 16 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2261
by: leegold2 | last post by:
Probably a newbie question about "state": My problem is I have a search form, so user enters a keyword <enter>, then this form posts to another page were the result are displayed. But this display page uses pagination to break the results up into several subsequent pages. The 1st page is OK, but 2nd...last display pages loose the key word variable I initially posted. Seems I could keep passing the keyword with GET, I already use GET...
6
10625
by: M.Kamermans | last post by:
I have an XSLT script that has to operate on some particularly nasty XML to turn it into a SQL databse, but 'entries' in the XML aren't actually unique, so their unique identifier is useless. I need to somehow create crosslinked tables using the XSLT, but can only do this by maintaining a counter for each line I write. Is there a way to create a proxy 'increment' function that lets me maintain a counter variable? - Mike Kamermans
4
2038
by: lost hope | last post by:
hey guys, on the main page of my site, i have a login area (user/pass text boxes). when the user submits the form, the page is reloaded with with a global php variable "loggedIn" set to true. i also store the username and password in the page in a hidden form -- so that it can be passed to other pages on the site through standard navigation (maintaining the "loggedIn" status). however, is there any way to save this information if the...
3
4291
by: ARobi | last post by:
I have developped an Access database with a lot of coding. The size of the database without data is about 5 meg. I am ready to copy the database to a client PC which already has a legal version of Access installed. 1.I am used to work with software such has C++ which basically save the program in many files but I notice that Access VBA save all data into a one big file. Any way I can brake it in multiple files? 2. If I make a change in...
0
1502
by: Dinesh Upare | last post by:
Hi, I want to fire events of Datatgrid without maintaining the view state. If I disable the ViewState then the events are not fired. The reason I don't want to maintain view state is because its too heavy when the data increases. Is there any way I only write the ViewState which is required to fire the dataGrid Events? I tried to override the SaveViewState and SavePageStateToPersistanceMedium
5
2007
by: Chris Hughes | last post by:
I have an environment with many thousands of client machines uploading data files several times each day to a web server via HTTP PUT. To avoid disk I/O (for performance), I am implementing a HTTP handler to intercept and process incoming data without touching the disk. I cannot detect PUT requests with my handler (don't know if this is even supported), so I'm redirecting all requests to the handler as POST using an ISAPI filter. I...
27
1881
by: Raymond | last post by:
They say it's easier, but has anyone tried maintaining an ASP.NET site without the source code of the dlls? This was not a problem with classic ASP, all the code was almost always just in text files, easily viewable and most importantly readily AVAILABLE on the site, to anyone access to the site's folder. But just imagine, bunch of companies out there, managed by non-technical people, who have had a bunch of outside
0
1320
by: mark.norgate | last post by:
Hi I'm having a problem in adding controls to a page programmatically in response to a button click. Composite user controls added programmatically in the CreateChildControls() method work fine; they maintain their state as expected. Cool and groovy. However, since CreateChildControls() is called before the method that responds to the button click, say AddControl_Click(), for some reason, this control does not maintain its
2
973
by: =?Utf-8?B?RGVyZWs=?= | last post by:
Does anyone know if there is an idiots guide to maintaining Active Directory using VB.NET. I have found bits and pieces about ldap_add, ldap_modify etc on the web but I could do with more hand holding. -- Derek
3
1661
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors which take a while to fix because the error stink: Forget to set ASP.NET 2.0="Parser Error Message: Could not load type" '*.Global' is ambiguous: it could come from assembly=I deleted the
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.