Encoding IPv4 Address to HexBinary

X

xxyyzz

Please help me out


1. What is meant by HexBinary Encoding,how is this done?
2. How must i convert a IPv4 Address to HexBinary Format ???



Thnx
Fernando
 
U

usenet

Please help me out

1. What is meant by HexBinary Encoding,how is this done?
2. How must i convert a IPv4 Address to HexBinary Format ???

Thnx
Fernando

The schema datatypes spec defines a hexBinary format. You can see it
at:

http://www.w3.org/TR/xmlschema-2/#hexBinary

Basically each byte is represented by two ASCII hexadecimal
characters.

It's also common in schemas to represent IP addresses using xs:string
and then restrict that with a pattern along the lines of:

<xs:pattern value="[1-9][0-9]{0,2}(\.[1-9][0-9]{0,2}){3}"/>

You can refine the pattern if you like to take into account that you
don't get IP addresses like 876.432.354.974, but that's too much like
hard work for me!

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================
 
X

xxyyzz

Please help me out
1. What is meant by HexBinary Encoding,how is this done?
2. How must i convert a IPv4 Address to HexBinary Format ???
Thnx
Fernando

The schema datatypes spec defines a hexBinary format. You can see it
at:

http://www.w3.org/TR/xmlschema-2/#hexBinary

Basically each byte is represented by two ASCII hexadecimal
characters.

It's also common in schemas to represent IP addresses using xs:string
and then restrict that with a pattern along the lines of:

<xs:pattern value="[1-9][0-9]{0,2}(\.[1-9][0-9]{0,2}){3}"/>

You can refine the pattern if you like to take into account that you
don't get IP addresses like 876.432.354.974, but that's too much like
hard work for me!

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================

Pete,
do mean dat we convert the IP to hex and then dat hex to ASCII

ex: (90.21.2.101)

IP 90. 21. 2. 101
HEX 5a 15 02 65

HEX to ASCII

HEX 5 a 1 5 0 2 6 5
ASCII 35 61 31 35 30 32 36 35

Waiting for your response,
Thanx,
Fernando
 
U

usenet

Pete,
do mean dat we convert the IP to hex and then dat hex to ASCII

ex: (90.21.2.101)

IP 90. 21. 2. 101
HEX 5a 15 02 65

HEX to ASCII

HEX 5 a 1 5 0 2 6 5
ASCII 35 61 31 35 30 32 36 35

Waiting for your response,
Thanx,
Fernando

Looking at it, the reference to ASCII didn't really help much!

You stop at the hex stage, then join them all up. An example in an
XML instance would be something like:

<ipv4>5a150265</ipv4>

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top