2010-09-06 7 views
0

J'ai besoin d'aide avec une transformation xsl, je n'ai aucune idée de comment commencer parce que je suis novice.xslt 1.0 aide à la transformation

Je possède ce schéma xml:

<?xml version="1.0" encoding="utf-8"?> 
<GetUserCollectionFromSiteResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"> 
<GetUserCollectionFromSiteResult> 
    <GetUserCollectionFromSite> 
     <Users> 
      <User ID="87" Sid="S-1-5-21-2025429265-1935655697-839522115-7617" Name="Falco Lannoo" LoginName="Domain\flannoo" Email="[email protected]" Notes="" IsSiteAdmin="False" IsDomainGroup="False" /> 
      <User ID="31" Sid="S-1-5-21-2025429265-1935655697-839522115-2721" Name="John Smith" LoginName="Domain\jsmith" Email="[email protected]" Notes="" IsSiteAdmin="False" IsDomainGroup="False" /> 
     </Users> 
    </GetUserCollectionFromSite> 
</GetUserCollectionFromSiteResult> 

Et je veux transformer ceci:

<ns0:userInfo xmlns:ns0="http://Sharepoint.userInfo"> 
    <ID>218</ID> 
    <Name>Falco Lannoo</Name> 
</ns0:userInfo> 

Je veux choisir le nœud où l'loginname = « Domaine \ flannoo ". Tout le monde peut me aider à cette transformation, il doit être en XSLT 1.0

merci

Répondre

1

Cette feuille de style:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:ns0="http://Sharepoint.userInfo" 
xmlns:soap="http://schemas.microsoft.com/sharepoint/soap/directory/" 
exclude-result-prefixes="soap"> 
    <xsl:template match="soap:User[@LoginName='Domain\flannoo']"> 
     <ns0:userInfo> 
      <xsl:apply-templates select="@*" /> 
     </ns0:userInfo> 
    </xsl:template> 
    <xsl:template match="@*"/> 
    <xsl:template match="@ID|@Name"> 
     <xsl:element name="{name()}"> 
      <xsl:value-of select="." /> 
     </xsl:element> 
    </xsl:template> 
</xsl:stylesheet> 

Avec l'entrée correcte:

<GetUserCollectionFromSiteResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"> 
    <GetUserCollectionFromSiteResult> 
     <GetUserCollectionFromSite> 
      <Users> 
       <User ID="87" Sid="S-1-5-21-2025429265-1935655697-839522115-7617" Name="Falco Lannoo" LoginName="Domain\flannoo" Email="[email protected]" Notes="" IsSiteAdmin="False" IsDomainGroup="False" /> 
       <User ID="31" Sid="S-1-5-21-2025429265-1935655697-839522115-2721" Name="John Smith" LoginName="Domain\jsmith" Email="[email protected]" Notes="" IsSiteAdmin="False" IsDomainGroup="False" /> 
      </Users> 
     </GetUserCollectionFromSite> 
    </GetUserCollectionFromSiteResult> 
</GetUserCollectionFromSiteResponse> 

Sortie:

<ns0:userInfo xmlns:ns0="http://Sharepoint.userInfo"> 
    <ID>87</ID> 
    <Name>Falco Lannoo</Name> 
</ns0:userInfo> 
+0

ok, merci beaucoup :) –

+0

@Rise_against: Vous êtes bienvenu. –

0

Voici une alternative à la réponse d'Alejandro. C'est surtout une question de style, mais cela peut être pertinent si vous devez l'intégrer dans une feuille de style plus complexe.

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:ns0="http://Sharepoint.userInfo" 
xmlns:soap="http://schemas.microsoft.com/sharepoint/soap/directory/" 
exclude-result-prefixes="soap"> 
    <xsl:template match="/"> 
    <xsl:apply-templates select="//soap:User[@ID='87']"/> 
    </xsl:template> 
    <xsl:template match="soap:User"> 
     <ns0:userInfo> 
      <ID><xsl:value-of select="@ID"/></ID> 
      <Name><xsl:value-of select="@Name"/></Name> 
     </ns0:userInfo> 
    </xsl:template> 
</xsl:stylesheet> 
Questions connexes