Zero Padding

I have a value (stored in a local variable) that I want to zero-pad to keep
the length (number of chars) the same.  Is there some easy way to do this? 
I was looking at XPATH and it seems like there are some formatting functions
that could possible do this.  Does anyone have a good example of how to do
this?  Thanks.


0
Matt
9/13/2007 2:46:40 AM
novell.id-manager.drivers 10360 articles. 2 followers. Follow

5 Replies
570 Views

Similar Articles

[PageSpeed] 46
Get it on Google Play
Get it on Apple App Store

Matt,

Using IDM 3.5 I would add an ECMAScript function like the one shown at the 
foot of this posting to my Driver and then if I wanted to pad with zeros 
on the left to a length of 13 I would invoke it in a Policy similar to this:

<do-set-local-variable name="matts-string-to-pad-lv" scope="policy">
 <arg-string>
  <token-xpath expression="es:padOneEnd($matts-string-to-pad-lv,13,'0',1)"/>
 </arg-string>
</do-set-local-variable>


(not forgetting to put xmlns:es="http://www.novell.com/nxsl/ecmascript" in 
the policy's non-java extension namespace



Rgds - M



function padOneEnd(stringToPad, requiredLength, padCharacter, endToPad) {
//
// Function to pad a string at the left or right end
// stringToPad is the string that needs to be padded
// requiredLength is the length that the string should be after padding
// padCharacter is the character with which to pad)
// endToPad is the end where the padding should be added (1 for Left end 
- 2 for Right end)
//
if (typeof(stringToPad)    == "undefined") { var stringToPad    = '';  }
if (typeof(requiredLength) == "undefined") { var requiredLength = 0;   }
if (typeof(padCharacter)   == "undefined") { var padCharacter   = ' '; }
if (typeof(endToPad)       == "undefined") { var endToPad       = 1;   }
//
if (requiredLength + 1 >= stringToPad.length) {
switch (endToPad){
case 1:
stringToPad = Array(requiredLength + 1 - stringToPad.length).join(padCharacter) 
+ stringToPad;
break;
case 2:
stringToPad = stringToPad + Array(requiredLength + 1 - stringToPad.length).join(padCharacter);
break;
default:
stringToPad = Array(requiredLength + 1 - stringToPad.length).join(padCharacter) 
+ stringToPad;
break;
}
}
return stringToPad;
} 


0
Martyn
9/13/2007 6:58:06 AM
"For convenience, the prefixes js and es are both implicitly mapped to 
http://www.novell.com/nxsl/ecmascript unless otherwise explicitly defined."

http://www.novell.com/documentation/idm35/policy/data/policyxpathexpression.html

--

Father Ramon


Martyn Durrant wrote:
> 
> (not forgetting to put xmlns:es="http://www.novell.com/nxsl/ecmascript" 
> in the policy's non-java extension namespace
> 
0
Father
9/13/2007 11:37:02 AM
Start with 10000 instead of 0000001?

Matt Weisberg wrote:
> I have a value (stored in a local variable) that I want to zero-pad to keep
> the length (number of chars) the same.  Is there some easy way to do this? 
> I was looking at XPATH and it seems like there are some formatting functions
> that could possible do this.  Does anyone have a good example of how to do
> this?  Thanks.
> 
> 
0
Jim
9/13/2007 12:53:29 PM
Matt Weisberg wrote:

> 
> I have a value (stored in a local variable) that I want to zero-pad to =
keep
> the length (number of chars) the same.  Is there some easy way to do =
this? 
> I was looking at XPATH and it seems like there are some formatting =
functions
> that could possible do this.  Does anyone have a good example of how to =
do
> this?  Thanks.

<do-set-local-variable name=3D"padded">
	<arg-string>
		<token-substring length=3D"13" start=3D"-13">
			<token-text xml:space=3D"preserve">0000000000000</token-text>
			<token-local-variable name=3D"unpadded"/>
		</token-substring>
	</arg-string>
</do-set-local-variable>

Cheers, Lothar

-- 

0
lothar
9/13/2007 2:05:17 PM
Thanks for all the suggestions.  I've not used the ECMAscript stuff myself,
but it looks like it is quite powerful (guess I need to read up on
ECMAScript).  

But Lothar's solution is quite simple and elegant.. I used it and it works
great! Thanks everyone.

Matt



>>> On 9/13/2007 at 10:05 AM, in message <xn0fb5l0b4q5ed8000@10.110.8.174>,
<lothar.haeger@mummert.de> wrote:
> Matt Weisberg wrote:
> 
>>
>> I have a value (stored in a local variable) that I want to zero-pad to 
> keep
>> the length (number of chars) the same.  Is there some easy way to do 
> this?
>> I was looking at XPATH and it seems like there are some formatting 
> functions
>> that could possible do this.  Does anyone have a good example of how to 
> do
>> this?  Thanks.
> 
> <do-set-local-variable name="padded">
> 	<arg-string>
> 		<token-substring length="13" start="-13">
> 			<token-text xml:space="preserve">0000000000000</token-text>
> 			<token-local-variable name="unpadded"/>
> 		</token-substring>
> 	</arg-string>
> </do-set-local-variable>
> 
> Cheers, Lothar
> 
> --
0
Matt
9/13/2007 4:51:57 PM
Reply:

Similar Artilces:

Driver Id and Driver Version not coming while creating the U
Hi, I have got a few Novell Products on my machine. some of them are running on VMPlayer( windows 2003 server) . The products on VMPLayer are : eDirectory 8.8 Identity Manager 3.5.1, iManager The products on my local machine are: Identity Manager User Application Novell designer. When I create a User Provisioning driver in the Identiy Manager using iManager, the driver gets created succssfully. It comes to the running state. But I do not get the driver id and driver version( it says, "atrribute not found") in the driver's detail information. This means the dri...

no option for adding print drivers in manage driver store
Im working on getting a oes2 linux server setup. Im trying to get iprint going. Ive created the driver store, print manager, etc. per the instructions. But when I go to the manage driver store tab in iManager I dont have the option to add print drivers. -- ddhottinger ------------------------------------------------------------------------ --____KJJQAWKZEFECWQHAJTTG____ Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; modification-date="Thu, 24 Mar 2010 06:47:43 -0400" are you going ...

Error trying to get a ID from the ID Driver with IDM4
I call the ID Driver to get an ID from the loopback driver and I get the error message : 11:12:19 604 Drvrs: Loopback services ST: DirXML Log Event ------------------- Driver: \ECA-META\eca\services\DriverSet1\Loopback services Channel: Subscriber Status: Error Message: Code(-9131) Error in vnd.nds.stream://ECA-META/eca/services/DriverSet1/Loopback+services/Subscriber/sub-event-idsa-15juil-2010#XmlData:80 : Error evaluating XPATH expression 'token-xpath("id:getNextID($RMIServer,$RMIPort,$UIDRule,$IDClient,$Tracelevel)")' : com.novell.xml.xpath.XPathEvaluationEx...

Known issues with Microsoft Driver manager and SQL Server driver ?
Hello, Are there any known issues with Microsoft Driver Manager hosting both SQL Server driver and Sybase Embedded Database drivers(ASA) ? Thanks, Chethan please clarify this asi quite honestly I have no clue what you are asking. DriverManager will keep track of all loaded JDBC drivers and use the 1st driver which matches the URL. > Hello, > > Are there any known issues with Microsoft Driver Manager > hosting both SQL Server driver and Sybase Embedded > Database drivers(ASA) ? > > Thanks, > Chethan > > ...

ID-Provider Driver
Novell Identity Manager 3.6 Windows Server 2003 R2 eDirectoy 8.8. SP3 Hi I want to develop a ID-policy based on followin rules: Prefix-GivenName[1]Surname[1]-AutoIcremnetNumber And these policies will be consumed by ID-Client(Identity Manager). So long , I have created ID Provider-driver, and configured it to be run as a RMI server (without ID Generation-Map) and Without defining Attributes in the ID-provider driver Filter. And I have created a NULL driver with some policies which invokes id:getNextID() method to get a Unique ID for newly created users. But my...

Delphi XE3 FireDAC TADConnection: Firebird driver not in Driver ID list
Delphi XE3 Enterprise FireDAC TADConnection Firebird driver not in Driver ID list Hi to all, I use Delphi XE3 Enterprise and have just installed FireDAC 7.0.1, but trying the sample "getting started" application, I can't find Firebird in the Driver ID list. I can see ADS, ASA, DataSnap, etc but no Firebird. By the way, all the DBExpress applications are running fine with Firebird. Is something I have missed? Hernando. Hello Hernando 'FB' driver ID was introduced in FireDAC v 9.0.1 (XE5). Before that existed only 'IB' driver ID. To workaround ...

[ODBC Driver Manager] Data source name not found and no default driver specified
I connecting to microsoft excel throu powerbuilder ,with dsn less connection. code like this sqlca.odbc = "odbs" sqlca.dbparm = "connectionstring='{driver= microsoft excel driver(*.xls)};dbq = 'd:\new\credit.xls'uid = '';pwd='';'" connec using sqlca; but i get above document title error please anybody help me pravin It's ConnectString, not ConnectionString ... and you have some errant quotes. Given you didn't spell "connect" right in "Connect using sqlca", I'm guessing you retyped here rather tha...

ODBC Driver Manager] Data source name not found and no default driver specified
Im rewriting an old asp page (that still works fine) that connects to an access database using a system dsn.  The asp page is written in perlscript, not that it matters.  However, my asp.net page cant seem to connect.  Im using the OdbcConnection object and trying to create an instance like so - new OdbcConnection(connStr), where connStr is my connection string that is just simply the dsn name ("DSN=mydsn")When I call open, i get the following: - - - - -An exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll but was not handled in user codeAdditi...

Printer driver deleted immediately after printer driver installation by remote printer management
I have a Windows 2000 Pro SP4 with Novell Client 4.9 SP2. The printer drivers installed after the user login, but it will be deleted immediately after a meanwhile. The system event log show "Printer xxxx is pending deleted". And finally no network printer is installed on client side. I tried to add the printer driver manaually by access NDPS Controlled Printer, Windows alerted that it cannot locate the printer and cannot download the printer driver, but it can shows the printer status is "Ready" at add printer dialog. Any advice about this? Thanks. What first comes...

[IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
hi all,  I am getting this error "[IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed", I am uing XP,and SP3 packs. The main Prob is the same code is running on one system...when i run in other system it is giving this error....   thanks murthy    Thanks & Regards,Murthy. Hi murthysrn, I don't know what's your connection string, but I recommend you to check it again and ensure it's correct. You may take a look at the connection strings samples in this link: http://www.connectionstrings.com/ Also, pleas...

ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
I am Building my first ASP.Net login page and I get the following error when I attemptto access a MS Access database file.  ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.Odbc.OdbcException: ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failedSource Error: Line 64: 'Calls Data...

Printer driver deleted immediately after printer driver installation by remote printer management #2
I have a Windows 2000 Pro SP4 with Novell Client 4.9 SP2. The printer drivers installed after the user login, but it will be deleted immediately after a meanwhile. The system event log show "Printer xxxx is pending deleted". And finally no network printer is installed on client side. I tried to add the printer driver manaually by access NDPS Controlled Printer, Windows alerted that it cannot locate the printer and cannot download the printer driver, but it can shows the printer status is "Ready" at add printer dialog. I also tried to reinstall the Novell Cli...

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I receive an error message reading "SQLSTATE=IM002[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" when I try to run my old PB4 app in Windows 2000. I know nothing about odbc. Could anyone please tell me how to solve this (my database is an old MS Access 97 db)? Thanks very much in anticipation. Martine Gu�bel mgu@writetc.be Please refrain from crossposting. This error indicates that you do not have a DSN defined on the machine -or- that the application is 16 bit and much of the 16 bit support has been dropped in Win2k...

ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed #2
Hi All,       I am getting this Error  When I am connecting to Remote System DSN Connection.Can I have the solution to this Error?  Thanks & Regards,Murthy. Your connection string is probably wrong try something like this... "mySystemDSN;Uid=myUsername;Pwd=myPassword"Hope that helps  Techie (.Net Knowledge at its Best)We make a living by what we get, but we make a life by what we give.::: Winston Churchill ::: How does your connection string look like?Mark replies as answers if they helped you solve the problem. murthysrn: ...

Web resources about - Zero Padding - novell.id-manager.drivers

Optimal asymmetric encryption padding - Wikipedia, the free encyclopedia
and subsequently standardized in PKCS#1 v2 and RFC 2437 . The OAEP algorithm is a form of Feistel network which uses a pair of random oracles ...

Clintonworld is centre of pocket padding universe
Clinton nostalgia is being replaced by Clinton neuralgia.

MP sorry for padding his resume
State Liberal MP David Southwick apologises for misleading personal information on his website.

Former treasurer Peter Costello warns tax reform hard without 'padding' in public opinion, more difficult ...
Peter Costello warns the Government tax reform will be difficult and that it may not have the political capital to pull it off.

Padding and the Contractor
If padding hours is a problem in Biglaw, imagine what would happen if you paid lawyers by the hour.

Contractor Accuses LA Times of Padding Circulation Figures
In 2007, the U.S. Attorney’s office in Brooklyn announced it was ceasing prosecution of Tribune publications Newsday and Hoy for padding circulation ...

That's Not Padding, My Resume's Just Fat
That's Not Padding, My Resume's Just Fat

Recalls: 2013 Ford C-Max Hybrid recalled over lack of roof padding
Filed under: Hybrid , Minivan/Van , Wagon , Recalls , Safety , Ford Ford is recalling 33,021 units of its 2013 C-Max Hybrid not equipped with ...

The truth behind padding your CV
When looking for a job, every little bit counts — as long as it’s true.

Rams, Edward Jones Dome Cover Concrete with Padding After Reggie Bush's Injury - Bleacher Report
On the heels of injuries suffered by San Francisco 49ers running back Reggie Bush and Cleveland Browns quarterback Josh McCown at the Edward ...

Resources last updated: 12/19/2015 9:41:03 PM