PDA

View Full Version : Ignore certain entries in XML???


wwweeesss
11-Mar-2005, 01:50 PM
The XML Tidy plugin works great for my purposes. What I was wondering, is how could I ignore certain values? For example I have a timestamp that is put into some of my .xml files which is unimportant to me. If that is the only difference, I want to ignore it. I tried setting up a regular expression to mark anything between <timestamp> and </timestamp> as unimportant but I'm having no success. Anyone done this before?

chrroe
11-Mar-2005, 02:01 PM
Hi Wes!

Could you please post a short example of your xml-file?


Bye
Christoph

Chris
11-Mar-2005, 03:39 PM
It depends on how your files are formatted.

It is probably easiest to mark using Delimited text instead of a regular expression, with <timestamp> to </timestamp> unimportant.

A regular expression will only work if the text is all on a single line. As long as it is on a single line, the regexp <timestamp>.*</timestamp> might work.

wwweeesss
14-Mar-2005, 09:31 AM
Here is an example. When looking directly in the file itself, everything is on one line, which is why XML Tidy helps me so much. For this file I want to ignore what is between the <xsd:documentation> tags.

<xsd:schema elementFormDefault="qualified" targetNamespace="http://www.ibm.com/websphere/crossworlds/2002/BOSchema/App_Audit" xmlns:App_Audit_Audit="http://www.ibm.com/websphere/crossworlds/2002/BOSchema/App_Audit_Audit" xmlns:App_Audit_AuditInfo="http://www.ibm.com/websphere/crossworlds/2002/BOSchema/App_Audit_AuditInfo" xmlns:App_Audit_TransactionInfo="http://www.ibm.com/websphere/crossworlds/2002/BOSchema/App_Audit_TransactionInfo" xmlns:bx="http://www.ibm.com/websphere/crossworlds/2002/BOSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:annotation><xsd:documentation>Thu Feb 24 14:04:11 EST 2005</xsd:documentation></xsd:annotation><xsd:import namespace="http://www.ibm.com/websphere/crossworlds/2002/BOSchema/App_Audit_Audit" schemaLocation="App_Audit_Audit.xsd" /><xsd:element name="App_Audit"><xsd:annotation><xsd:appinfo><bx:boDefinition version="3.0.0"><bx:appSpecificInfo>elem_fd=unqualified;attr_fd=unqualified</bx:appSpecificInfo></bx:boDefinition></xsd:appinfo></xsd:annotation><xsd:complexType><xsd:sequence><xsd:element name="XMLDeclaration" minOccurs="0"><xsd:annotation><xsd:appinfo><bx:boAttribute><bx:appSpecificInfo>type=pi</bx:appSpecificInfo><bx:attributeInfo isForeignKey="false" isKey="true" /></bx:boAttribute></xsd:appinfo></xsd:annotation><xsd:simpleType><xsd:restriction base="xsd:string"><xsd:maxLength value="255" /></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name="ROOT" minOccurs="0"><xsd:annotation><xsd:appinfo><bx:boAttribute><bx:appSpecificInfo>elem_name=Audit</bx:appSpecificInfo><bx:attributeInfo isForeignKey="false" isKey="false" /><bx:childObjectInfo relationship="Containment" version="3.0.0" /></bx:boAttribute></xsd:appinfo></xsd:annotation><xsd:complexType><xsd:sequence><xsd:element ref="App_Audit_Audit:App_Audit_Audit" /></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="ObjectEventId" type="xsd:string" minOccurs="0" /></xsd:sequence><xsd:attribute name="version" type="xsd:token" default="0.0.0" /><xsd:attribute name="delta" type="xsd:boolean" default="false" /><xsd:attribute name="locale" type="xsd:string" default="" /><xsd:attribute name="verb" use="required"><xsd:simpleType><xsd:restriction base="xsd:NMTOKEN"><xsd:enumeration value="Create" /><xsd:enumeration value="Delete" /><xsd:enumeration value="Retrieve" /><xsd:enumeration value="Update" /></xsd:restriction></xsd:simpleType></xsd:attribute></xsd:complexType></xsd:element></xsd:schema>

chrroe
14-Mar-2005, 11:20 AM
Hi!

As Chris already suggested you should use definition of unimportant text.
With your file I tried the following:

- Open the rule for XML Tidy
- Go to the Importance tab.
- Select the up most New button.
- Here enter at Beginning with and and ending with <xsd:documentation> and </xsd:documentation> .

When now comparing two files you can choose via the View menu, whether these unimported differences are to be highligthed or completely ignored.

Works fine :D .



Bye
Christoph

wwweeesss
16-Mar-2005, 10:08 AM
Thanks very much guys! Marking the unimportance via the delimited settings worked great. :)