My target is to extract specific keys out of KeyPass(2.x) xml format by xsl.
The KeyPass XML looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<KeePassFile>
<Meta>
<Generator>KeePass</Generator>
</Meta>
<Root>
<Group>
<UUID>NqDrFtUxs0SiwVPehBpONg==</UUID>
<Name>ExampleDatabase</Name>
<Entry>
<String>
<Key>Notes</Key>
<Value>Notes</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">Password</Value>
</String>
<String>
<Key>Title</Key>
<Value>Sample Entry</Value>
</String>
<String>
<Key>URL</Key>
<Value>http://keepass.info/</Value>
</String>
<String>
<Key>UserName</Key>
<Value>User Name</Value>
</String>
</Entry>
<Entry>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">12345</Value>
</String>
<String>
<Key>Title</Key>
<Value>Sample Entry #2</Value>
</String>
<String>
<Key>URL</Key>
<Value>http://keepass.info/help/kb/testform.html</Value>
</String>
<String>
<Key>UserName</Key>
<Value>Michael321</Value>
</String>
</Entry>
<Group>
<UUID>mec/n7Hkf0uZMDMrZyaO7A==</UUID>
<Name>General</Name>
</Group>
<Group>
<UUID>mBKJFmgV6UOQQmXlmhZt/A==</UUID>
<Name>Windows</Name>
</Group>
<Group>
<UUID>CKbqJW0RwUKdUT/go0EnJg==</UUID>
<Name>Network</Name>
</Group>
<Group>
<UUID>B6yKdAooSkOj6+uvrGDURQ==</UUID>
<Name>Internet</Name>
</Group>
<Group>
<UUID>4IG7YyeaY0yHbnuUtJMx5A==</UUID>
<Name>eMail</Name>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">1.Os0mnyE6ESeL1yGnTsX6</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry1</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">Os0mnyE6ESeL1yGnTsX6</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry1</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
</Entry>
</History>
</Entry>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">2.RlYOCgZDirnjbjcu8Td2</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry2</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Login für den Plesk Server.</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">RlYOCgZDirnjbjcu8Td2</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry2</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
</Entry>
</History>
</Entry>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">3.RzJsbTeK29MS1GnUiTlb</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry3</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">RzJsbTeK29MS1GnUiTlb</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry3</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
</Entry>
</History>
</Entry>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">4.8BONlQkfKRHpPdTL3luh</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry4</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">8BONlQkfKRHpPdTL3luh</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry4</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>[email protected]</Value>
</String>
</Entry>
</History>
</Entry>
</Group>
<Group>
<UUID>A/OASMueGE+ZBzEpvrTjow==</UUID>
<Name>Homebanking</Name>
</Group>
</Group>
<DeletedObjects />
</Root>
</KeePassFile>
I want to access the value of a single ‘Value’ tag. So for example the Value of the Group eMail in the Kategory Title or Password. The value would then be (eMail/Title:) ‘Entry1’. I just need the xsl to gather the information of the KeePass.xml.
2
Answers
My current solution is:
I assume you mean the
UserName
key, which occurs four times in thatGroup
, once in each childEntry
. In that case you need to select the thirdEntry
to obtain the third email. In your code you can achieve that using a positional predicate toEntry
: