[oXygen-user] Find and replace with lowercase
Oxygen XML Editor Support
support at oxygenxml.com
Thu Jul 11 05:05:12 CDT 2013
Hello,
Unfortunately that's not possible with the Find/Replace tool from
Oxygen. It only supports Java regular expressions which do not have the
ability to lowercase/uppercase (as opposed to Perl 5 regular expressions).
Alternative solutions:
1. (for less then a hundred matches) Use "Find All" to obtain a list
with all matches and then manually navigate them (Ctrl+Shift+] /
Ctrl+Shift+[) and for each match use the Document > Source > To Lower
Case action. You can assign a shortcut to this action in Options > Menu
Shortcut Keys (search in the filter for 'to lower').
2. (for a hundred or more) Use an XSLT stylesheet that processes the XML
and lowercases the values of those attributes @fileref).
e.g.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<!-- Match document -->
<xsl:template match="/">
<xsl:apply-templates mode="copy" select="."/>
</xsl:template>
<xsl:template
match="@fileref[parent::*:imagedata/parent::*:imageobject/parent::*:mediaobject]"
mode="copy">
<xsl:attribute name="fileref" select="lower-case(.)"/>
</xsl:template>
<!-- Deep copy template -->
<xsl:template match="node()|text()|@*" mode="copy">
<xsl:copy>
<xsl:apply-templates mode="copy" select="@*"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template>
<!-- Handle default matching -->
<xsl:template match="*"/>
</xsl:stylesheet>
This will remove the DOCTYPE if any, so you'll have to manually put it back.
Also note that by default a transformation expands the attribute
defaults (from the DTD/schema). You can disable that in the 'Advanced
options' (cogwheel button) of the Saxon 9 transformer when configuring
the transformation scenario.
Regards,
Adrian
Adrian Buza
oXygen XML Editor and Author Support
Tel: +1-650-352-1250 ext.202
Fax: +40-251-461482
support at oxygenxml.com
http://www.oxygenxml.com
On 11.07.2013 11:48, Yudong Chen wrote:
>
> Hello, everyone,
>
> I was trying to find and change some attribute values to lowercase in
> hundreds of xml files, using the Find and Replace feature of Oxygen,
> but without success.
>
> For example, there are many values reading like this (just example):
>
> <mediaobject>
> <imageobject>
> <imagedatafileref="../images/AbcdEfg.png"width=".81cm"/>
> </imageobject>
> </mediaobject>
>
> I succeeded in finding all of those values using regular expression
> but I don't know how to replace them with their lowercase versions.
>
> Have you ever succeeded in doing the same thing? Would you please
> share the way you did it? Or it is just impossible with Oxygen?
>
> Thanks,
>
> Yudong
>
>
>
> _______________________________________________
> oXygen-user mailing list
> oXygen-user at oxygenxml.com
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20130711/2a26e85b/attachment.html
More information about the oXygen-user
mailing list