I am new with XSLT and I also have developed an Audit Trail system, each action(e.g Edit,Add New and Remove) will be track for each object, I have inserted OldValue and NewValue of object as XML into DB
In UI I will show user the audit details as following pic:
But I have decided show 'Full Name' instead of 'FullName' or 'Calendar Name' instead of 'CalendarName' or in future I would like use multiple language for captions.
Generated XML of OldValue is:
<BasicInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UserIdentify>100</UserIdentify>
<UserName>user1</UserName>
<FullName>Ali Hassanabadi</FullName>
<Email>ali.h@test.com</Email>
<LogInCounter>0</LogInCounter>
<Title>Dr.</Title>
<Label />
<Theme>dark-hive</Theme>
<Language>English</Language>
<CalendarName>Gregorian</CalendarName>
<ExpireDate xsi:nil="true" />
<Status>1</Status>
</BasicInfo>
So XSLT file can be use to convert XML to XHTML, but the problem is I have a lot of classes they are using Auditing system. I think this is not good to define XSLT file for each class so I came to this conclusion to define custom attribute for each property which specified property's caption, something like this:
public class BasicInfo : IAuditable
{
[AuditingTitle("Full Name")]
public string FullName
{
get;
set;
}
}
now when the Old Value or New Value are showing, I find class name and it's properties by the calling assembly name as well as for each property I must find it's attribute title by the reflections.
Something like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/Found">
<div>
<b>Here bind to found title of properties</b>
<xsl:value-of select="PropertyValue"/>
</div>
</xsl:template>
</xsl:stylesheet>
So is there a way to define one XSLT(dynamic) compatible with all generated XMLs ?
Thanks in advance.