473,597 Members | 2,520 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 1712


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
2250
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
10611
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
2025
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
4271
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
1488
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
1998
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
1862
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
1315
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
962
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
1648
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
7971
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7893
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
8276
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
5847
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
5436
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3889
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...
0
3932
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1243
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.