[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Need a programmic way to read xslt file, and dete

Subject: RE: Need a programmic way to read xslt file, and determine the mappings defined.
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Mon, 8 Nov 2004 15:44:19 -0000
xslt read attribute
> No, my desire is to get a xslt file and with java determine
> the mapping. Then determine how to reverse eng the process to
> find my source.
>
> Background: My app uses xslt to translate data model A to
> data model B. My user wishes to not to write certain
> attributes in a table in data model B.
> He selects the attributes to mask. I would then like to
> inform him of the source that was used to map to that target
> attribute, and inform him of what other targets that same
> source was mapped to.
>
> So I need to something to parse the xslt file, and expose
> interfaces that allow me to easily determine this mapping.

A technique I've used for a completely different requirement may be
useful here.  What you need to do is add a unique identifier to each
source element, then copy that through to the result.  When the user
'masks' of a section of the HTML, you can find out which unique
identifiers have been masked and then re-parse the source xml to locate
the source elements.

The unique I identifier I used was the element index, added using an
XMLFilter as the source is read in.  A separate XMLFilter adds an
attribute to every literal result element of the stylesheet as it gets
parsed to copy the element index through to the result.  For example:

Source XML:
<root>
  <foo/>
  <bar/>
</root>

Source XML after XMLFilter:
<root id="1">
  <foo id="2"/>
  <bar id="3"/>
</root>

Stylesheet:
<xsl:template match="foo">
  <div>
    <xsl:value-of select="."/>
  </div>
</xsl:template>

Stylesheet after XMLFilter:
<xsl:template match="foo">
  <div elementIndex="{@id}">
    <xsl:value-of select="."/>
  </div>
</xsl:template>

Result when applied:
<div elementIndex="2"/>

So now when your user selects an area of the screen you can access the
elementIndex attribute and then query the source xml for an element with
a matching number, and locate <foo/>.  That is, you know that that <div>
was generated from the template that processed the source <foo/>
element.

The element indexes and AVT's are all added at transform time using
XMLFilters so it keeps you source and stylesheets clean with a minimal
performance impact.

I've been a bit brief but I hope you get the idea,

Cheers
anderw

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.