Topics

Best way to change @alt to #DITAv2-0 #images

Kristen James Eberlein
 


What have folks found to be the best/easiest/cleanest way to change @alt to <alt> in DITA source? To clarify:

Deprecated usage:
<image href="image.png" alt="My wonderful image"/>

New usage:
<image href="image.png">
    <alt>My wonderful image</alt>
</image>

@alt has been deprecated since DITA 1.2 and will be removed in DITA 2.0.

I'm currently working with a small group that has about a thousand images with @alt; I'd love to be able to fix this for them ...

--
Best,
Kris

Kristen James Eberlein
Chair, OASIS DITA Technical Committee
OASIS Distinguished Contributor
Principal consultant, Eberlein Consulting LLC
www.eberleinconsulting.com
+1 919 622-1501; kriseberlein (skype)

Zoë Lawson
 

I’m sure that there’s a way to do it with Oxygen refactoring.

However I usually go towards an XSLT script that copies everything, with a template for fixing whatever needs fixing.

Since I generally am doing some sort of major source control restructure and cleanup every 18 months or less, I have some scripts lying around to start from.

Zoë

Zoë Lawson


From: main@dita-users.groups.io <main@dita-users.groups.io> on behalf of Kristen James Eberlein <kris@...>
Sent: Monday, March 2, 2020 3:15:29 PM
To: dita-users@groups.io <dita-users@groups.io>
Subject: [dita-users] Best way to change @alt to <alt> #DITAv2.0 #images
 

What have folks found to be the best/easiest/cleanest way to change @alt to <alt> in DITA source? To clarify:

Deprecated usage:
<image href="image.png" alt="My wonderful image"/>

New usage:
<image href="image.png">
    <alt>My wonderful image</alt>
</image>

@alt has been deprecated since DITA 1.2 and will be removed in DITA 2.0.

I'm currently working with a small group that has about a thousand images with @alt; I'd love to be able to fix this for them ...

--
Best,
Kris

Kristen James Eberlein
Chair, OASIS DITA Technical Committee
OASIS Distinguished Contributor
Principal consultant, Eberlein Consulting LLC
www.eberleinconsulting.com
+1 919 622-1501; kriseberlein (skype)

ekimber@contrext.com
 

If the markup is reliable then a global regular expression search and replace is sufficient, which of course is easy to do with Oxygen. Something like:

From:

<image(\s+href="[^"]+")\s+alt="([^"]+)"\s*>

To:

<image$1><alt>$2</alt></image>

Cheers,

E.

--
Eliot Kimber
http://contrext.com


On 3/2/20, 2:15 PM, "Kristen James Eberlein" <main@dita-users.groups.io on behalf of kris@...> wrote:










What have folks found to be the best/easiest/cleanest way to
change @alt to <alt> in DITA source? To clarify:
Deprecated usage:
<image href="image.png" alt="My wonderful image"/>

New usage:
<image href="image.png">
<alt>My wonderful image</alt>
</image>

@alt has been deprecated since DITA 1.2 and will be removed in
DITA 2.0.
I'm currently working with a small group that has about a
thousand images with @alt; I'd love to be able to fix this for
them ...

--
Best,
Kris

Kristen James Eberlein
Chair, OASIS DITA Technical Committee
OASIS Distinguished Contributor
Principal consultant, Eberlein Consulting LLC
www.eberleinconsulting.com <http://www.eberleinconsulting.com>
+1 919 622-1501; kriseberlein (skype)

Wayne Brissette
 

I was going to suggest that as well, but thought, really XSLT should be used here since technically XML isn’t just text. But you know me… I’ll use whatever tool is the fastest and easiest and in this case I do think a regex would solve it. 



On Mar 2, 2020, at 2:50 PM, ekimber@... wrote:

If the markup is reliable then a global regular expression search and replace is sufficient, which of course is easy to do with Oxygen. Something like:

From:

<image(\s+href="[^"]+")\s+alt="([^"]+)"\s*>

To:

<image$1><alt>$2</alt></image>

Cheers,

E.

--
Eliot Kimber
http://contrext.com



ekimber@contrext.com
 

This might be a slightly better formulation:

From:

<image(\s*href="[^"]+")?\s+alt="([^"]+)"(\s*href="[^"]+")?/>

To:

<image$1$3><alt>$2</alt></image>

That should handle the attributes being in either order.

Cheers,

E.
--
Eliot Kimber
http://contrext.com


On 3/2/20, 2:50 PM, "ekimber@..." <main@dita-users.groups.io on behalf of ekimber@...> wrote:

If the markup is reliable then a global regular expression search and replace is sufficient, which of course is easy to do with Oxygen. Something like:

From:

<image(\s+href="[^"]+")\s+alt="([^"]+)"\s*>

To:

<image$1><alt>$2</alt></image>

Cheers,

E.

--
Eliot Kimber
http://contrext.com


On 3/2/20, 2:15 PM, "Kristen James Eberlein" <main@dita-users.groups.io on behalf of kris@...> wrote:










What have folks found to be the best/easiest/cleanest way to
change @alt to <alt> in DITA source? To clarify:
Deprecated usage:
<image href="image.png" alt="My wonderful image"/>

New usage:
<image href="image.png">
<alt>My wonderful image</alt>
</image>

@alt has been deprecated since DITA 1.2 and will be removed in
DITA 2.0.
I'm currently working with a small group that has about a
thousand images with @alt; I'd love to be able to fix this for
them ...

--
Best,
Kris

Kristen James Eberlein
Chair, OASIS DITA Technical Committee
OASIS Distinguished Contributor
Principal consultant, Eberlein Consulting LLC
www.eberleinconsulting.com <http://www.eberleinconsulting.com>
+1 919 622-1501; kriseberlein (skype)

Radu Coravu
 

I would go with an XSLT refactoring operation, the example in the Oxygen User's Manual is for exactly this case of changing a DITA image @alt to <alt>:

https://www.oxygenxml.com/doc/ug-editor/topics/custom_operation_sample-x-tools.html

Regards,
Radu

Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

On 3/2/2020 11:38 PM, ekimber@... wrote:
This might be a slightly better formulation:
From:
<image(\s*href="[^"]+")?\s+alt="([^"]+)"(\s*href="[^"]+")?/>
To:
<image$1$3><alt>$2</alt></image>
That should handle the attributes being in either order.
Cheers,
E.
--
Eliot Kimber
http://contrext.com
On 3/2/20, 2:50 PM, "ekimber@..." <main@dita-users.groups.io on behalf of ekimber@...> wrote:
If the markup is reliable then a global regular expression search and replace is sufficient, which of course is easy to do with Oxygen. Something like:
From:
<image(\s+href="[^"]+")\s+alt="([^"]+)"\s*>
To:
<image$1><alt>$2</alt></image>
Cheers,
E.
--
Eliot Kimber
http://contrext.com
On 3/2/20, 2:15 PM, "Kristen James Eberlein" <main@dita-users.groups.io on behalf of kris@...> wrote:
What have folks found to be the best/easiest/cleanest way to
change @alt to <alt> in DITA source? To clarify:
Deprecated usage:
<image href="image.png" alt="My wonderful image"/>
New usage:
<image href="image.png">
<alt>My wonderful image</alt>
</image>
@alt has been deprecated since DITA 1.2 and will be removed in
DITA 2.0.
I'm currently working with a small group that has about a
thousand images with @alt; I'd love to be able to fix this for
them ...
--
Best,
Kris
Kristen James Eberlein
Chair, OASIS DITA Technical Committee
OASIS Distinguished Contributor
Principal consultant, Eberlein Consulting LLC
www.eberleinconsulting.com <http://www.eberleinconsulting.com>
+1 919 622-1501; kriseberlein (skype)

Roger Sheen
 

On Monday, 2020-03-02, at 21:15 CET, Kristen James Eberlein wrote:

What have folks found to be the best/easiest/cleanest way to change
@alt to <alt> in DITA source?

Several plug-ins are available in the DITA-OT plug-in registry to handle these cases.

Robert Anderson’s deprecated-dita plug-in reports markup like @alt attributes:
https://www.dita-ot.org/plugins#!org.metadita.deprecated.

For usage instructions, see https://github.com/robander/deprecated-dita.

Jason Fox’s Validator plug-in builds on this report to automatically fix deprecated markup:
https://www.dita-ot.org/plugins#!com.here.validate.svrl.

For details, see https://github.com/jason-fox/com.here.validate.svrl.

Hope that helps,

Roger


--

https://www.dita-ot.org/dev/ · DITA Open Toolkit Documentation