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

moving to Styler only onscreen stylesheet

sureshmaddela
1-Newbie

moving to Styler only onscreen stylesheet

Hi,



Can someone help in getting rid of the issue/warning I am running with? Any
advice is welcome.



Assumptions:
7 REPLIES 7

Hi Suresh,

I think the PI is forcing Arbortext to look for your FOSI stylesheet. The way I see it, you have three options:

1. Somehow figure out how to suppress the stylesheet warning. The downside is that you may end up also suppressing legitimate warnings.

2. Clean all the CMS content of the stray PIs that are causing the problem. The downside being that this would probably be very hard to organise with a large and active set of users and content.

3. Clean XML files on the way into Arbortext. Have some sort of hook function that executes when a user loads a document, but before Arbortext looks for the stylesheet. The hook function (eg. an ACL script) would simply remove the stray PIs before Arbortext looks for the stylesheet.

Cheers,
Gareth

Hi Gareth,



Thanks for the response.



1. Somehow figure out how to suppress the stylesheet warning. The downside
is that you may end up also suppressing legitimate warnings.

>>>>>>>> Iis there a way to suppress only this specific warning, as we are
interested in other warnings?



2. Clean all the CMS content of the stray PIs that are causing the problem.
The downside being that this would probably be very hard to organise with a
large and active set of users and content.

>>>>>>>> As I have already mentioned in my previous mail, this may not be
an acceptable solution by users as they have huge set of documents if they
have to change.



3. Clean XML files on the way into Arbortext. Have some sort of hook
function that executes when a user loads a document, but before Arbortext
looks for the stylesheet. The hook function (eg. an ACL script) would
simply remove the stray PIs before Arbortext looks for the stylesheet.

>>>>>>>> I did try menu load hook, using add_hook("menuloadhook",
"pickStylesheet"), but ended up with same warning. The “pickStylesheet”
function picks the required onscreen stylesheet (C:\epicuser\doctypes\
asdocbook \ asdocbook.style).

function pickStylesheet(win, file){

local customDir = get_custom_dir();

local docType, absoluteFilePath;

global publicIdType;



if(customDir == "){

response("Custom Application details
missing:" . caller(0));

}

docType = "\\Doctypes\\asdocbook\\";

baseFileName = "asdocbook.";



absoluteFilePath = $customDir . $docType . $baseFileName . "style";

stylesheet_select($absoluteFilePath, 0, current_doc());



}



What is kind of hook function I need to add to simply remove the stray PIs
in xml document before Arbortext looks for the stylesheet?

Is there a way to add back these processing instructions before saving?



Thanks and Regards,

Suresh.

Hi Suresh,

Regards your feedback to #1 and #3, I don't have the answers and would need to do further investigation. Let's see if any of the other Adepters have experience in this area.

Cheers,
Gareth

Hi any,

Can some one share their ideas no this?


Hi Gareth,
Anyway, thanks for you response and valuable thoughts,



Regards,
Suresh.


Hi Suresh--



You could try setting the stylesheetassociations option to "off" (you
can do this on the Advanced panel of the Preferences dialog), and that
should tell Arbortext to ignore those stylesheet PI's.



If that works for you, you can then add



set stylesheetassociations=off



to your custom/init/init.acl file and that should make sure everyone
using your custom directory has the correct setting to avoid the
stylesheet-not-found warning.



--Clay





Clay Helberg

Senior Consultant

TerraXML


Hi Suresh--



Wait, I just tested that, and it doesn't work at all like I expected
based on the documentation. It doesn't ignore the PI's, but does strip
them out when you save the document. In other words, the exact opposite
of what you want. So, never mind, sorry to get your hopes up.



--Clay





Clay Helberg

Senior Consultant

TerraXML


The following works with a free-form XML document I used for testing.

It uses the "editfilehook" to catch a document just before it is displayed
for editing and enumerates the style sheet associations in the document,
looking for one that is set for editor display and whose path ends with a
particular string. It then deletes this association (leaving the document
in "modified" state) and selects the default free-form FOSI, instead.

You may want to use doc_set_stylesheet_association to replace the PI with a
different one, though I think you'll still need to do the stylesheet_select
call, as PI processing has already finished, by this point. The
"editfilehook1" function just provides a wrapper around the function that
does the work, passing the result of current_doc to it, to give you a
little flexibility for testing and such.

function fixStylesheetAssociation(doc)
{
local ssTarget = "test1.style";
local ssNew = $aptpath . '\doctypes\freeform\freeform.fos';
local ssCount, ssInfo[], i, ss, len = length(ssTarget) - 1;
ssCount = doc_num_stylesheet_associations(doc);
if (ssCount < 0) { return; }
for (i = 1; i <= ssCount; i++) {
if (!doc_get_stylesheet_association(doc, i, ssInfo)) { return; }
ss = substr(ssInfo["href"], length(ssInfo["href"]) - len);
if (ssInfo["media"] == "editor" && ss == ssTarget) {
doc_delete_stylesheet_association(doc, i);
stylesheet_select(ssNew, 0, doc);
return;
}
}
}
function editfilehook1(code) { fixStylesheetAssociation(current_doc()); }
add_hook("editfilehook", editfilehook1);

-Brandon 🙂


Announcements