0

I am very new to using XSLT. I've been tasked with getting our C-Cure 9000 system to accept clearances from active directory security groups. I've gotten as far as listing the groups of the user, but have not been able to figure out how to strip the unnecessary text.

This is what I'm trying to work with:

    <GroupsAll>CN=Doors - Test,OU=C-Cure Test,OU=Security Groups,DC=test,DC=local|CN=Doors - Test2,OU=C-Cure Test,OU=Security Groups,DC=test,DC=local|CN=VPN Admins2,OU=VPN,OU=Security Groups,DC=test,DC=local|CN=VPN Admins,OU=VPN,OU=Security Groups,DC=test,DC=local|CN=GPO Cert Testing,OU=Information Technology,OU=Security Groups,DC=test,DC=local|CN=Muni Bldg 8th,OU=Municipal Building,OU=Milestone Camera Access,OU=Security Groups,DC=test,DC=local</GroupsAll>

I need to strip out any group that does not contain "Doors" and then remove the "CN=" and ",OU=C-Cure Test,OU=Security Groups,DC=test,DC=local".

I need to get it to look like:

<ClearancesAll>Doors - Test,Doors - Test2</ClearancesAll>

Ive tried a ton of different code, but don't know enough to make it work.

Any help or suggestions on how to get this to work would be greatly appreciated!

Thanks!

Edit:

This is the code i see:

<CrossFire culture-info=" en-US">
  
<SoftwareHouse.NextGen.Common.SecurityObjects.Personnel ImportMode=" Default">
 <Text1>*****</Text1>
 <FirstName>******</FirstName>
 <GroupsAll>CN=Doors - Test,OU=C-Cure Test,OU=Security Groups,DC=test,DC=local|CN=Doors - Test2,OU=C-Cure Test,OU=Security Groups,DC=test,DC=local|CN=VPN Admins2,OU=VPN,OU=Security Groups,DC=test,DC=local|CN=VPN Admins,OU=VPN,OU=Security Groups,DC=test,DC=local|CN=GPO Cert Testing,OU=Information Technology,OU=Security Groups,DC=test,DC=local|CN=Muni Bldg 8th,OU=Municipal Building,OU=Milestone Camera Access,OU=Security Groups,DC=test,DC=local</GroupsAll> 
 <GUID>0xADD5234ACA37CE*********</GUID>
 <LastName>*****</LastName>
</SoftwareHouse.NextGen.Common.SecurityObjects.Personnel>
  
</CrossFire>

and this is the "stylesheet template" the software gives me to work with:

<?xml version ="1.0" encoding="utf8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

<!-- Parameters assigned at runtime. -->
<xsl:param name="paramCurrentTimestamp">20001231173010</xsl:param>
<xsl:param name="paramCurrentDT" >12/31/2000 5:30:10 PM</xsl:param>
<xsl:param name="paramCurrentCulture">en-US</xsl:param>

<!-- The transformation below provides trivial default copy of everything. -->
<xsl:template match="*|@*">
  <xsl:copy>
    <xsl:apply-templates select="*|@*|text()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="@*">
  <xsl:copy />
</xsl:template>
<!-- End of customizable area. -->

</xsl:stylesheet>
ccip4911
  • 1
  • 2
  • Post you actual input XML. You say you want to filter out some Group elements, but I don't see this anywhere. – Sebastien Oct 17 '22 at 12:43
  • 1
    XSLT is designed to process data structured as XML. It is not very good (esp. XSLT 1.0) at processing data structured as delimited text - which is what seems to be the main task here. Which XSLT processor will you be using? You could probably benefit from some extension functions, if your processor supports them. – michael.hor257k Oct 17 '22 at 13:00
  • Thats the hard part. The XML is all internally generated. The program itself pulls all the info from LDAP. The documentation explains i can only use XLST to modify the information it pulls from LDAP. The program only shows me info like i posted above. – ccip4911 Oct 17 '22 at 13:04
  • @ccip4911 there is no way to write an XSLT transform if you don't see the actual XML input format. – Sebastien Oct 17 '22 at 13:18
  • 1. You should be able use a stylesheet with only the *identity transform* template to see the original XML. 2. Please tell us which XSLT processor you are using. If you don't know, find out - see here how: https://stackoverflow.com/a/25245033/3016153 – michael.hor257k Oct 17 '22 at 13:38
  • xslt version 1.0 – ccip4911 Oct 17 '22 at 13:49
  • That is NOT what I asked (twice). – michael.hor257k Oct 17 '22 at 13:54
  • Processor/Vendor is Microsoft – ccip4911 Oct 17 '22 at 14:04
  • 1
    I have closed your question as a duplicate of a question about tokenizing, because I believe that is the first and foremost problem here. Once you learn how to do that, you can ask about filtering out the unwanted tokens (if you cannot figure it out on your own). – michael.hor257k Oct 17 '22 at 14:08
  • My reading of the problem is that they've got XML, but they don't know what XML they've got. But I'm only guessing. – Michael Kay Oct 17 '22 at 15:26

0 Answers0