Skip to main content

Retaining Document URI after transformation

1 reply [Last post]
rlubke
Offline
Joined: 2003-08-21
Points: 0

Hey Folks,

I have some code that uses XSLT under the covers to transform EE deployment descriptors from DTD based documents to their Schema-based counterparts.

This works 99% of the time until I hit an issue where we need to build a URL relative to the location of the source document. Before the transform, we have a valid Document URI, but after the transform that information is lost.

I'm wondering if there is a directive I can embed within the stylesheet itself to cause this information to be propagated to the transform result?

My current workaround is to manually copy the URI from the source to the result. Is there a better way?

Thanks,
-rl

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

XML DOM doesn't remember the document URI, so I'm bit confused as to how it can be "lost".

If you mean you are using XSLT to produce SAX events and your ContentHandler uses SAX Locator (for example to report errors with line numbers), the usual trick we use inside JAXB/WS RI is to first parse it to DOM with location information added as attributes, run XSLT, then write SAX Filter to use those attributes to fake a Locator.

It's far more work than it should be, but oh well.