cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Storing styler output in attributes

DuanGauche
1-Newbie

Storing styler output in attributes

Hi all,


I have a custom XSD and am I styling for PDF using the APP engine in Editor 6.0 M10.


I am looking for a way to store things like numbering and other context related information in attributes. An example of this would be storing the font family and size as it is applied by the stylesheet in the attributes of the element being styled.


This will mean that an external system which receives the XML data would be able to tell that a title was "printed" in a certain font and size.


I have had a look at using xpath in genetated text, but have not been able find a logical solution. I assume one would need to capture the generated text for numbering in some sort of variable and then write that variable's value into the attribute of the relevant element.


I would appreciate a pointer in the right direction.


Thanks,


Duan

4 REPLIES 4

Hi Duan,


Interesting problem for which I don't have any answer other than writing anXSL taking the stylesheet as an input. Line numbers sound like even more of a challenge since they require multiple formatting passes.


Purists (beware), many of whomwho don't live in the real world where we need to communicate with the less-than-pure, would say you're missing the point of course ...


Regards,


- Lou Argyres

Continuing Education of the Bar - California
Oakland, CA



In Reply to Duan Gauche:



Hi all,


I have a custom XSD and am I styling for PDF using the APP engine in Editor 6.0 M10.


I am looking for a way to store things like numbering and other context related information in attributes. An example of this would be storing the font family and size as it is applied by the stylesheet in the attributes of the element being styled.


This will mean that an external system which receives the XML data would be able to tell that a title was "printed" in a certain font and size.


I have had a look at using xpath in genetated text, but have not been able find a logical solution. I assume one would need to capture the generated text for numbering in some sort of variable and then write that variable's value into the attribute of the relevant element.


I would appreciate a pointer in the right direction.


Thanks,


Duan


Hi Duan-



I had an application that required this sort of thing a while back, and
I ended up taking exactly the approach that Lou recommends. I wrote an
XSLT stylesheet that takes both the source document and the stylesheet
as inputs and generates an "augmented" version of the source document
with formatting attributes added to each element as output. But I have
to say that essentially re-implementing Styler as an XSLT stylesheet was
no picnic. There are lots of references that occur in a Styler
stylesheet and you have to make sure your XSLT is dereferencing them
correctly. And you have to make sure that you get priorities to match up
correctly too; in Styler you can have a particular formatting attribute
defined in more than one place (e.g. main Element, one or more
conditions under the Element, a property set, etc.), and Styler has
rules to determine which value "wins", so you have to make sure the
rules in your XSLT match those that Styler uses.



To be honest, I wouldn't recommend going down this path unless your use
case is really critical and justifies a significant investment of time
and resources.



--Clay



Clay Helberg

Senior Consultant

TerraXML


Here is another idea, seeing as the OP is using APP.



If you upgrade to 6.0 M020 (release next week?) then I believe that will
ship with the APP v11 component. APP v11 allows writing to the DOM
representation of the main XML stream.



1. Implement APP Stylersheet "overrides" for each context/condition for
which you are interested in capturing the font information.

2. Use APP function variable ^[prop] to get the current information,
eg. ^[prop tf,l] will get the active font longname and ^[prop th] will get
the active font height.

3. Use APP DOM functions to write that information into the main XML
stream as attributes on-the-fly.

4. Finally have some mechanism at the end of the formatting/printing
passes which serialises the amended DOM to disk.



Or a more low-tech version of the same thing:



1. As above.

2. As above.

3. At each ^[prop] place where you are capturing the current font
state, instead of writing to the DOM, store the font information into an
array. The font information array sould be indexed against the current
character position in the main XML stream.

4. Once formatting/printing have completed, iterate through the font
information array using APP primitive commands or Perl. The idea is to move
to each character position in the XML and insert the required attributes
into the markup at that character position. (The trick is to ensure you keep
offsetting the character positions stored in your array to account for the
previous attributes you just inserted J)



If none of that sounds good, then my final idea for this morning would be to
use the APP XML print driver to print your page to XML. The resulting XML
format is like a PDF description of a page and does not resemble your
original source markup at all. However it does capture most of the styling
information.



Either way Duan it sounds like you're in for some serious mucking about with
Styler/APP/XSLT (unless your application is very simple). What you are
effectively asking for is to track all styling decisions made during
composition and there is nothing out of the box for that.



-Gareth



Hi Duan,


Sounds very similar to something we've recently been doing for a customer that augments the XML, in this instance with line and page break information. This follows a similar idea to what Gareth is suggesting but augmenting the XML with custom PI's durring the formatting pass and returns this to Editor (outside of the integrated APP and using a direct APP template). So this does work well if you chose this approach.


Regards


Chris





Chris Western
tformat ltd
Arbortext sVAR/MSP
www.tformat.com


Top Tags