& turning to &

I'm doing an operation reformat and trying to use the & in a text box. 
In the trace it looks ok in the policy, but when it gets to the actual
xml value it turns into this:

<modify-attr attr-name="EG">
<remove-all-values/>
<add-value>
<value>&amp;</value>
</add-value>
</modify-attr>

Can I fix this in policy builder or by escaping the character somehow? 
Or do I need a stylesheet to fix the problem?


-- 
nate_spears
------------------------------------------------------------------------



0
nate
3/10/2008 2:46:01 PM
novell.id-manager.drivers 10360 articles. 2 followers. Follow

6 Replies
1008 Views

Similar Articles

[PageSpeed] 10

It isn't a problem. The "XML value" you refer to is just that: XML. As 
such, the &amp; character reference is correct.

Perin

nate spears wrote:
> I'm doing an operation reformat and trying to use the & in a text box. 
> In the trace it looks ok in the policy, but when it gets to the actual
> xml value it turns into this:
> 
> <modify-attr attr-name="EG">
> <remove-all-values/>
> <add-value>
> <value>&amp;</value>
> </add-value>
> </modify-attr>
> 
> Can I fix this in policy builder or by escaping the character somehow? 
> Or do I need a stylesheet to fix the problem?
> 
> 
0
Perin
3/10/2008 2:53:50 PM
Imagine that I'm then using this value in a delimited text driver.  How
do I convert the XML 
&amp;
back into a regular
&
before I output it as text?  This is syntactically tricky when trying
to do it in a stylesheet.  Is it possible I may have to use java to
process the output?


-- 
nate_spears
------------------------------------------------------------------------
nate_spears's Profile: http://forums.novell.com/member.php?userid=7564
View this thread: http://forums.novell.com/showthread.php?t=315300

0
nate
5/21/2008 2:06:02 PM
I will answer my own question for anyone who comes behind me.

I am trying to send the & to a DT file.  In XML the & is represented as
&amp; so the final XSLT stylesheet that parses the values of the
operational attributes just lumps it in as &amp; into the DT output.

I don't want &amp; - I just want &.  I've modified the output-field
template in the final stylesheet to look like this:

	<xsl:template name="output-field">
		<xsl:param name="field-value"/>		
		 <xsl:value-of select="es:replaceTags($field-value)"/>
	</xsl:template>

and the ECMAScript function looks like so:

function replaceTags(fixMe)
{
//importPackage(java.lang);
//System.out.println("\n" + fixMe.getClass().getName() + "\n");
fixMe = (fixMe+"").replace("&amp;","&");
return fixMe;
}

I was calling replace directly on fixMe, and getting an error.  After
quite a bit of getting really annoyed, I added the lines which are
commented out above, to discover that fixMe is in fact a
com.novell.xml.xpath.NodeSet, so I added the +"" to cast it as a
string.

This works, but I feel like the +"" is pretty much a hack.  Does anyone
know how I can pass a string in directly?  I tried changing the way I
was calling output-field:

<xsl:call-template name="output-field">
	<xsl:with-param name="field-value" select="*[(@attr-name =
'some_attr')][1]/value[1]/text()"/>
</xsl:call-template>

which didn't seem to have any effect on the type.


-- 
nate_spears
------------------------------------------------------------------------
nate_spears's Profile: http://forums.novell.com/member.php?userid=7564
View this thread: http://forums.novell.com/showthread.php?t=315300

0
nate
5/23/2008 8:46:02 PM
You're solving a problem that doesn't exist. You will get exactly the 
same output in your file without the hoops you are jumping through.

As long as you are using the delimited text driver, and your final 
document has no elements in it - just text (which should always be the 
case if you're just output delimited text instead of XML, then the 
driver knows to output just text to the file and not do serialized XML.

If that were not the case, your exercise in ECMAScript would be an 
exercise in futility because the stylesheets aren't creating serialized 
XML at all, they are creating a DOM tree that represents the logical 
structure of the XML in which the escaping you are worrying about 
doesn't even exist. The escaping is a required artifact of serializing 
the logical structure of the XML into a character stream, which happens 
for trace purposes, but doesn't happen when the the DT driver writes to 
the file unless the DOM tree has elements in it instead of just text.

The only other way you would be getting the escaped version in your 
output file is if the string you were worrying about really was supposed 
to be &amp; because that was the original text, in which case it would 
be showing up in the XML trace as &amp;amp; instead of just &amp;.

Incidentally, the answer to your ECMAScript question about passing a 
string instead of a nodeset would be to convert the nodeset to a string 
before passing it by applying the string() function:

  <xsl:value-of select="es:replaceTags(string($field-value))"/>

Or if you wanted to convert inside of ecmascript, just call the 
toString() method:

  fixMe.toString()

or applying the string conversion function:

String(fixMe)


-Father Ramon


nate spears wrote:
> I will answer my own question for anyone who comes behind me.
> 
> I am trying to send the & to a DT file.  In XML the & is represented as
> &amp; so the final XSLT stylesheet that parses the values of the
> operational attributes just lumps it in as &amp; into the DT output.
> 
> I don't want &amp; - I just want &.  I've modified the output-field
> template in the final stylesheet to look like this:
> 
> 	<xsl:template name="output-field">
> 		<xsl:param name="field-value"/>		
> 		 <xsl:value-of select="es:replaceTags($field-value)"/>
> 	</xsl:template>
> 
> and the ECMAScript function looks like so:
> 
> function replaceTags(fixMe)
> {
> //importPackage(java.lang);
> //System.out.println("\n" + fixMe.getClass().getName() + "\n");
> fixMe = (fixMe+"").replace("&amp;","&");
> return fixMe;
> }
> 
> I was calling replace directly on fixMe, and getting an error.  After
> quite a bit of getting really annoyed, I added the lines which are
> commented out above, to discover that fixMe is in fact a
> com.novell.xml.xpath.NodeSet, so I added the +"" to cast it as a
> string.
> 
> This works, but I feel like the +"" is pretty much a hack.  Does anyone
> know how I can pass a string in directly?  I tried changing the way I
> was calling output-field:
> 
> <xsl:call-template name="output-field">
> 	<xsl:with-param name="field-value" select="*[(@attr-name =
> 'some_attr')][1]/value[1]/text()"/>
> </xsl:call-template>
> 
> which didn't seem to have any effect on the type.
> 
> 
0
Father
5/23/2008 9:25:35 PM
Father Ramon,

Thank you for your analysis.  As it happens, I said that I was using
the DT driver and it made me look foolish, but I only said that to
avoid (unnecessarily, I thought) explaining what I am actually doing,
which is using a custom shim to make a network connection to pass the
text across.

Believe me, I would not have jumped through these hoops if I didn't
have an actual problem.

I'm not sure exactly what you are saying about the DOM tree, but it
sounds as if you have pointed out twice that the driver shim itself
will make sure &amp; doesn't get written to a file.

I probably don't understand exactly how the engine itself works.  My
impression was that the last stylesheet in the DT driver was
"converting" an XML document into a text stream which no longer has
meaning to the engine, since it is not in a recognizable format
anymore.  The engine, all uncaring (still in my imagination), then
passes that text stream without looking at it to the driver shim, which
also doesn't really care what it is, just that it needs to write it to
such and such a file.

Obviously I was wrong about some point (if not all points) of this
process - can you elucidate that for me?  Specifically, where/how does
the &amp; become just &, and if there is anything else I am wrong about
I'd like to know.  It matters to me because it may help me improve my
own shim.

Father Ramon;1565114 Wrote: 
> You're solving a problem that doesn't exist. You will get exactly the
> same output in your file without the hoops you are jumping through.
> 
> As long as you are using the delimited text driver, and your final
> document has no elements in it - just text (which should always be the
> case if you're just output delimited text instead of XML, then the
> driver knows to output just text to the file and not do serialized
> XML.
> 
> If that were not the case, your exercise in ECMAScript would be an
> exercise in futility because the stylesheets aren't creating
> serialized
> XML at all, they are creating a DOM tree that represents the logical
> structure of the XML in which the escaping you are worrying about
> doesn't even exist. The escaping is a required artifact of serializing
> the logical structure of the XML into a character stream, which
> happens
> for trace purposes, but doesn't happen when the the DT driver writes
> to
> the file unless the DOM tree has elements in it instead of just text.
> 
> The only other way you would be getting the escaped version in your
> output file is if the string you were worrying about really was
> supposed
> to be &amp; because that was the original text, in which case it would
> be showing up in the XML trace as &amp;amp; instead of just &amp;.
> 
> Incidentally, the answer to your ECMAScript question about passing a
> string instead of a nodeset would be to convert the nodeset to a
> string
> before passing it by applying the string() function:
> 
> <xsl:value-of select="es:replaceTags(string($field-value))"/>
> 
> Or if you wanted to convert inside of ecmascript, just call the
> toString() method:
> 
> fixMe.toString()
> 
> or applying the string conversion function:
> 
> String(fixMe)
> 
> 
> -Father Ramon
> 
> 
> nate spears wrote:
> > I will answer my own question for anyone who comes behind me.
> >
> > I am trying to send the & to a DT file.  In XML the & is represented
> as
> > &amp; so the final XSLT stylesheet that parses the values of the
> > operational attributes just lumps it in as &amp; into the DT output.
> >
> > I don't want &amp; - I just want &.  I've modified the output-field
> > template in the final stylesheet to look like this:
> >
> > 	<xsl:template name="output-field">
> > 		<xsl:param name="field-value"/>
> > 		 <xsl:value-of select="es:replaceTags($field-value)"/>
> > 	</xsl:template>
> >
> > and the ECMAScript function looks like so:
> >
> > function replaceTags(fixMe)
> > {
> > //importPackage(java.lang);
> > //System.out.println("\n" + fixMe.getClass().getName() + "\n");
> > fixMe = (fixMe+"").replace("&amp;","&");
> > return fixMe;
> > }
> >
> > I was calling replace directly on fixMe, and getting an error. 
> After
> > quite a bit of getting really annoyed, I added the lines which are
> > commented out above, to discover that fixMe is in fact a
> > com.novell.xml.xpath.NodeSet, so I added the +"" to cast it as a
> > string.
> >
> > This works, but I feel like the +"" is pretty much a hack.  Does
> anyone
> > know how I can pass a string in directly?  I tried changing the way
> I
> > was calling output-field:
> >
> > <xsl:call-template name="output-field">
> > 	<xsl:with-param name="field-value" select="*[(@attr-name =
> > 'some_attr')][1]/value[1]/text()"/>
> > </xsl:call-template>
> >
> > which didn't seem to have any effect on the type.
> >
> >


-- 
nate_spears
------------------------------------------------------------------------
nate_spears's Profile: http://forums.novell.com/member.php?userid=7564
View this thread: http://forums.novell.com/showthread.php?t=315300

0
nate
5/24/2008 1:06:02 AM
nate spears wrote:
> Father Ramon,
> 
> Thank you for your analysis.  As it happens, I said that I was using
> the DT driver and it made me look foolish, but I only said that to
> avoid (unnecessarily, I thought) explaining what I am actually doing,
> which is using a custom shim to make a network connection to pass the
> text across.

That explains a lot.

> Believe me, I would not have jumped through these hoops if I didn't
> have an actual problem.

Yes you have a problem, but the problem lies in your shim, and there are 
no hoops you can jump through in a stylesheet, policy, configuration, 
etc. that will solve it. You have to fix the shim.

> I'm not sure exactly what you are saying about the DOM tree, but it
> sounds as if you have pointed out twice that the driver shim itself
> will make sure &amp; doesn't get written to a file.

You've got it backwards. The &amp; doesn't exist in the document that 
passes through the engine or gets passed to your shim. It is your shim 
that turns it into the &amp;.

> I probably don't understand exactly how the engine itself works.  My
> impression was that the last stylesheet in the DT driver was
> "converting" an XML document into a text stream which no longer has
> meaning to the engine, since it is not in a recognizable format
> anymore.  The engine, all uncaring (still in my imagination), then
> passes that text stream without looking at it to the driver shim, which
> also doesn't really care what it is, just that it needs to write it to
> such and such a file.

(Please not that what follows is generally applicable to XML and not at 
all specific to IDM.)

Your problem is thinking of an XML document as the characters that you 
see spit out in the trace or written out to an XML file when the 
document is serialized, but that isn't what it is.  An XML document is 
an abstract tree data structure that consists of nodes, each node having 
properties like type, name, value, etc. The stream of characters or 
bytes that you are familiar with is one possible of that data structure, 
and the one that is most commonly used for storage, transport over the 
network, and human viewing & editing. This is known as the serialized 
form. But when programs deal with XML, they typically don't deal with 
the byte stream at all other than for reading and writing from storage 
or some communication medium like a socket. Programs that deal with XML 
typically deal primarily with other representations of the document and 
only deal the byte stream when they need to read/write from storage or a 
network transport or display to humans. The process of converting from 
the byte stream to the other representations is called parsing and the 
process of converting from the other representations is known as 
serialization.

One of the most common representations of XML used within programs is 
called the Document Object Model (DOM). DOM is the primary form used to 
represent XML within IDM, although it also supports conversion between 
serialized XML, DOM, and another representation called SAX. This 
conversion is handled by an object called XmlDocument, which is what the 
engine uses to pass the document to/from the shim. The documents in IDM 
typically start life as DOM and are never serialized except for display, 
transport, and storage, so if you have a driver that has tracing turned 
off, not running in the remote loader, and not using a driver that have 
a serialized XML based API, then DOM is the only form ever exists in.

Now the part that applies to you in this situation is that &amp; only 
ever exists in the serialized form of the XML and is required in the 
serialized form because the & is one of the characters that has special 
meaning in serialized form. It does not exist in the DOM form at all. 
The XSLT processor doesn't deal with XML in serialized form either; it 
deals with the DOM form. Trying to convert an &amp; to & or vice versa 
in a stylesheet is an exercise in futility because it doesn't exist 
there (unless of course the actual text being represented is trying to 
represent those characters and not just an &.) If you think what you 
have done with ECMAScript is working, you are mistaken because the &amp 
doesn't exist at that point (unless, as pointed out above, those 
characters are what was put into the document if the first place).

> Obviously I was wrong about some point (if not all points) of this
> process - can you elucidate that for me?  Specifically, where/how does
> the &amp; become just &, and if there is anything else I am wrong about
> I'd like to know.  It matters to me because it may help me improve my
> own shim.
> 

I hope it's clear by now that it is not a question of where/how the &amp 
becomes just &, but rather where/how just & is becoming &amp;, and the 
answer to that is in YOUR shim. When the document is sent you your shim 
as an XmlDocument it is in the DOM form. What you are probably doing to 
get your string to send across the network (haven't seen the code, so 
have to guess here) is calling XmlDocument.getDocumentString() on the 
XmlDocument object passed to the shim. getDocumentString() takes the 
original DOM representation and serializes to get the character stream 
you are familiar with, which is what turns & into &amp;. But you don't 
want serialized XML, you want the characters that are represented by the 
text nodes within the XML. In order to get those you are going to have 
to extract them from the DOM representation. Fortunately, that is not 
particularly difficult. Instead of the call to getDocumentString() you 
want to do something like:

org.w3c.dom.Document domDoc = doc.getDocument();
String myText = com.novell.xml.xpath.XPathUtil.getNodeValue(domDoc);

which is what the DT driver does when it detects that there are no 
elements in the document.


-Father Ramon
0
Father
5/24/2008 1:37:51 PM
Reply:

Similar Artilces:

&& In Generated Javascript Becomes &amp;&amp;
I am trying to write client side scripts in c#, asp.net V 1.4. The && operator is generated in the javascript as &amp;amp;, which causes errors.  How can I avoid this? (Code below)  Thanks in advance.   script = "<script language='javascript' type='text/javascript'>\n"; script += "if (Form1." + tbxA.ClientID + ".value == '' && "; script += "Form1." + tbxB.ClientID + ".value == '') {"; script += "Form1." + cbxC.ClientID + ".Checked = false;}"; ...

form ID &amp;quot;__aspnetForm&amp;quot;
I have a server form embeded in an ascx control. In the ascx, the form is defined like this:<form runat="server" id="IDName">On my development machine, the page rendered to the browser has the ID in the format of "ControlName:IDName":<form name="ControlName:IDName" method="post" action="Default.aspx" id="ControlName_IDName">However, on our live site, the form has the name "__aspnetForm":<form name="__aspnetForm" method="post" action="Default.aspx" id="__aspnetFor...

Convert &amp; to &
I have a Gridview that is populated by the 3 different users from selections made in a prior Form.  This gridview summarizes everything.  I then step through this Gridview and write the data to a history file on SQL. The problem I am having is, one column in this Gridview is a name column which contains the "&" symbol.  When I iterate the Gridview and populate the history file the & becomes &amp;.  I can't seem to figure out how to convert this properly.  Both data fields are nvarchar type.  Please help anyone. This is the code to tak...

&, &&, and backtracking.
------=_Part_20601_33098141.1189046184291 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline How do C<&> and C<&&> differ with respect to backtracking? For instance, "foobar" ~~ / <[a..z]>+ & [ ... ] /; Both sides of the C<&> happen in parallel, so I would guess that they both match "foo" then stop. Please correct me if that's wrong. Were we using the procedural conjunction: "foobar" ~~ / <[a..z]>+ && [ ... ] /; I would gues...

If & =&amp; in xml then { or }= what?
Hi frnds, some problem when using xml & is not compatible in xml file so we replace & with &amp;    like that i want to know what the characters which are not compatible with xml syntax for example when i m using { or } in xml file then its shwoing error msg. if anyone knows the soln then plz reply me. Thanks in advance.Regards,Hasan Mohiuddin Farooqihasan_farooqi@yahoo.co.in Hi Dear,Please find the Table. It contains the all special character list... quot " U+0022 (34) HTML 2.0 HTMLspecial ISOnum quotation mark (= APL quote) amp &am...

Replacement of & , &amp;
I was trying this java script inside a mozilla extension but the browser shows me error this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); XML Parsing Error: not well-formed at replace(/&/g,'&amp;') Any thoughts ? Thanks On Fri, 30 May 2008 10:26:19 -0700 (PDT), sb wrote: > I was trying this java script inside a mozilla extension but the > browser shows me error > this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); > ...

& where shown as &amp;
hai,     At runtime i will add values from textbox to datagrid using datatables.what my problem was , when i add as he & she in textbox it show as he &amps; she in the grid.how to solve this. Thanks in advance   cool.mugil:    At runtime i will add values from textbox to datagrid using datatables.what my problem was , when i add as he & she in textbox it show as he &amps; she in the grid.how to solve this.  Make sure you are not HTML encoding the input values.  Hai,    How to do stop html enc...

&amp; instead of &
I have gridview with the following code on row commandDim row As GridViewRow = gvBusinessLines.Rows(e.CommandArgument)txtBusinessLine.Text = CStr(row.Cells(1).Text) ''''''''''''''''''''''''''''''''''''''''''''''' When I have this text in gridview for example:"test & test2", when clicking on the button of the gridview, textbox is containing test &amp; test2How to avoide this other than re...

Kfarbair.com
Name: LeceHoigree Email: 101atmanga-kenseidotcom Product: eBay Companion Summary: Kfarbair.com - &#1489;&#1497;&#1514; &#1502;&#1500;&#1493;&#1503; &#1499;&#1508;&#1512;&#1497; & &#1495;&#1491;&#1512;&#1497;&#1501; &#1502;&#1512;&#1493;&#1493;&#1495;&#1497;&#1501; & &#1499;&#1508;&#1512; &#1489;&#1506;&#1497;&#1512; Comments: <a href=http://www.kfarbair.com><img>http://www.kfarbair.com/_images/_photos/photo_big8.jpg</img></a> ...

&amp;
C:\Program Files\ASP.NET Starter Kits\ASP.NET Portal (VBSDK)\PortalVBSDK\admin\Cardholders.aspx(174) : error BC30451: Name 'amp' is not declared.            __output.Write(Global.GetApplicationPath(Request) &amp; "/ASPNETPortal.css")                                                   ...

&&
Hi all=2C I have some arrays and like to trigger some events depending on which = array or combination of arrays contains data=2E What I tried was = something like=3A snippet if(=40dates =26=26 !=40themes =26=26 !=40cities) =7B =23do something with the data in =40dates =7D elsif(!=40dates =26=26 =40themes =26=26 !=40cities) =7B =23do somthing with =40themes =7D =2E=2E=2E Alas! I doesn=27t work=2E Using =22and=22 instead of =22=26=26=22 doesn=27= t help either=2E Or do I have to use =22=26=22 instead=2E Although it doesn=27t work eithe= r=2E = instead = ...

What the *$&@)%#(&!!???
Ok, a little off topic but I need help ASAP. I installed a mapping program this morning and ever since then, my computer has been going nuts. My IIS wouldn't work anymore...it wouldn't show any of my virtual directories...said there were none to manage. I re-installed that and it works now. *i think* Then I tried to browse to one of my local sites ... such as http://localhost/somesite, or http://localhost/dotnetnuke, etc. None of them work! They all point to the correct folders and have the default.aspx at the top of the documents list. All I get is a blank white page when I browse t...

@#%&*!@+%$&@
Name: Rick Kimmel Email: rick_kimmelatbellsouthdotnet Product: Firefox Summary: @#%&*!@+%$&@ Comments: Since I downloaded the latest Firefox version, every time I open it I'm assailed with a prompt telling me I need some kind of goddamned Registry Defender and it pisses me off! I already have registry software and it was free, thank you and I don't need yours. I'm looking around to find a new browser since Mozilla seems to have gone to Hell! Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CL...

and, or, &&, ||
Hello! I remember someone mentioning that there may be a precedence problem with "unexpected results" during a mathematical conditional test, using the keywords "and" and "or"...instead of the symbols (&& and ||). Is this true? Can anyone give me an example? Thanks much! cl __________________________________________________ Do You Yahoo!? Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com On Tue, 25 Sep 2001, Christine Lenda wrote: > I remember someone mentioning that there may b...

Web resources about - & turning to &amp; - novell.id-manager.drivers

Resources last updated: 12/6/2015 12:58:57 AM