Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6383635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:40:27+00:00 2026-05-25T02:40:27+00:00

I believe I have a very interesting problem to solve. I’ve a XML something

  • 0

I believe I have a very interesting problem to solve. I’ve a XML something like this :

<elements>
  <element name="nam1" val="John" xpos="10" ypos="10" />
  <element name="nam3" val="Mark" xpos="10" ypos="30" />
  <element name="nam4" val="Rick" xpos="50" ypos="30" />
  <element name="nam5" val="Jeff" xpos="10" ypos="50" />
  <element name="nam6" val="Dean" xpos="50" ypos="50" />
  <element name="nam2" val="Scott" xpos="50" ypos="10" />

The positions of the elements in the xml may not be sequential.

I’ve to convert this into a HTML table. The contents of the TRs and TDs need to be “dynamically” set based on xpos and ypos attributes of the XML .. output should be something like this :

<table>
    <tr>
       <td>John</td><td>Scott</td>
    </tr>
    <tr>
       <td>Mark</td><td>Rick</td>
    </tr>
    <tr>
       <td>Jeff</td><td>Dean</td>
    </tr>
</table>

Things get more complicated when the xpos or ypos are not exactly same, but slightly different for 2 adjoining elements ..
e.g.

<elements>
  <element name="nam1" val="John" xpos="10" ypos="12" />
  <element name="nam3" val="Mark" xpos="11" ypos="30" />
  <element name="nam4" val="Rick" xpos="53" ypos="32" />
  <element name="nam5" val="Jeff" xpos="09" ypos="52" />
  <element name="nam6" val="Dean" xpos="51" ypos="51" />
  <element name="nam2" val="Scott" xpos="50" ypos="10" />
</elements>

Any ideas how do I achieve this ? using xslt or Java/Javascript dom parser ? or anything else ? and how ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:40:28+00:00Added an answer on May 25, 2026 at 2:40 am

    I wouldn’t dare to attempt to solve this with XSLT – XSLT is good for simple, basic transformations. While it might be possible to pull it off, it will probably drive you insane in the process.

    As for solving it at all:

    1. Use rounding or similar methods to solve the “off by 1/2” problem
    2. Sort the data.
    3. Creating a table out of the sorted data should be trivial

    Now, I expect you to ask “and without sorting?” (because it’s too expensive, whatever). Answer: You will sort the data, one way or another. Creating a huge map in memory and add elements to it based on the coordinate is sorting. It’s just non-obvious.

    [EDIT] Maybe this trick will also work: Instead of a table, use div with position: absolute and scale the coordinates until the texts no longer overlap. That will emulate a table but whether it works for you depends on whether the coordinates actually mean something (i.e. they aren’t random but some other system uses them to lay out the data)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe I have a very common problem that affects developers with multiple versions
I have been told and I'm not sure I believe this: Removing white space
I have an interesting conundrum which I believe can be solved in purely SQL.
I am (unfortunately) developing an application in Excel 2000 VBA. I believe I have
I believe that I have successfully impersonated my own user account while running an
I have what I believe is a killer idea for an application. By definition,
I believe several of us have already worked on a project where not only
I have two issues both related to (I believe) my SQL Server setup. I
I have an Oracle server (version 9, I believe) and a MS SQL server
I am new to NHibernate and have found it extremely interesting. I have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.