473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Translated Offset to Source Offset

I was wondering if anyone has seen/knows of a solution to the
following: given a document that has been translated through xsl, if
you have a character offset in the translated document, can you get
back to a specific location in the original xml document.

I know the answer is yes, because this is how WYSIWYG editors work.
Almost any editor can give you a graphical representation of the xml
(usually using xsl), and any cursor movements reflect back to your
position in the xml. (Think of a split screen view with the translated
rendered view and the original xml).

So with no editor available, and taken to its basic elements (you only
have the translated document, the original xml, and the xsl), can you
map offsets back and forth (i.e. just like the WYWIWIG editor would)?
This may be easier if the translated document is valid XML, and there
is a full XPath to to the offset.... but I'm trying to figure out all
possibilities.

Thanks if anyone has any pointers on this one.
Jul 20 '05 #1
2 1749
In article <ba**************************@posting.google.com >,
Lance Riedel <lr*****@hotmail.com> wrote:
I was wondering if anyone has seen/knows of a solution to the
following: given a document that has been translated through xsl, if
you have a character offset in the translated document, can you get
back to a specific location in the original xml document.
No.
I know the answer is yes,
Oops.
because this is how WYSIWYG editors work.


Presumably they are unusually chummy with their XSLT implementations.

An XSLT implementation could provide extra information to let you
do this - say giving the offset of the source to which the template
was applied to produce the result - but it's not portable, just
part of the implementation.

I suppose it would be possible to transform a stylesheet (using a
stylesheet, naturally) to make it annotate the output with, say,
processing instructions that would help.

And of course given a particular XSLT implementation, it would be
possible to "instrument" it to produce the necessary information.

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #2
In article <ba**************************@posting.google.com >,
Lance Riedel <lr*****@hotmail.com> wrote:

% I know the answer is yes, because this is how WYSIWYG editors work.
% Almost any editor can give you a graphical representation of the xml
% (usually using xsl), and any cursor movements reflect back to your
% position in the xml. (Think of a split screen view with the translated
% rendered view and the original xml).

I wouldn't think that any WYSImolWYG editor that works on XML source
uses XSL in the process. The formatting is likely to be applied with
something more like CSS, so that the editor works directly on the
original tagged data, but the displayed output hides the tags.

% So with no editor available, and taken to its basic elements (you only
% have the translated document, the original xml, and the xsl), can you
% map offsets back and forth (i.e. just like the WYWIWIG editor would)?

In general, the content and structure of a transformed document is
different from the original, so there can be no mapping. One point
in the original might appear in more than one place in the target
(for instance, if the target is a report with summary information in
more than one format). Another point might not appear at all.

Even if you restrict your transformation to ensure a 1-1 correspondence,
keeping track of which bit in the source maps to which bit in the target
requires you to have state information, which XSLT doesn't allow. It
can be done using extensions, but you may be better off not using XSLT.

% This may be easier if the translated document is valid XML, and there
% is a full XPath to to the offset.... but I'm trying to figure out all
% possibilities.

It's not clear that XPath will be helpful in this, either. At least,
it would be less work for your extension to keep track of the node
in the result tree than for it to dynamically create an XPath
expression which returns that one node from the result tree.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christopher Li | last post by:
I am surprised to find out the mmap module in python always mmap from offset 0. So I just hack up some patch to allow it accept offset arguments. So here it is. Chris Add optional offset...
9
by: Sasha | last post by:
Hi, I am extending standard IEnumerator, and I was just wondering what is the best way to make enumarator safe? What do I mean by safe? Detect deletes and all... My idea is to have private Guid...
24
by: Christopher Benson-Manica | last post by:
Is there anything wrong with my attempt (below) at implementing something resembling a smart pointer? template < class T > class SmartPointer { private: T *t; public:
4
by: Gactimus | last post by:
Here is a program that encodes and decodes a text file. What I need to do is write a C++ program that requests 3 different file names. One filename is for the source file to be encoded, another is...
0
by: D. Dante Lorenso | last post by:
I need to know that original number of rows that WOULD have been returned by a SELECT statement if the LIMIT / OFFSET where not present in the statement. Is there a way to get this data from PG ?...
1
by: ThunderMusic | last post by:
Hi, I have to copy some data to an unmanaged array pointed by an IntPtr. The thing is Marshal.Copy only offers 4 parameters(not the actual parameters name but what I understood of them) : Source,...
2
by: primeau | last post by:
Hi, using either a sax or dom parser, ans preferably in java, is there a way of getting where an lement starts and finishes in a given document? <tag>abc<aa/></tag> where <tagstarts at 0 and...
8
by: printline | last post by:
Hello I have a problem which i hope someone can help me with. I have a website where customers can login and their current and previous orders. What i need now is for the customers to look...
8
by: Thomas Mlynarczyk | last post by:
Hello, I want to split a given string into tokens which are defined by regexes: // example tokens - a bit more complex in real $tokens = array( 'NUMBER' ='~^\d+~', 'NAME' ='~^+~', 'ANY' ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.