xsl-list
[Top] [All Lists]

RE: [xsl] Re: Writing xslt from DSML

2010-04-23 03:50:29

The code I gave you provides two rules: a rule for processing batchResponse
elements, which invokes processing of all its contained attr elements; and a
rule for processing attr elements.  That will handle any number of
batchResponse elements and any number of attr elements.

Unfortunately the example input you have isn't well-formed so I'm having to
make guesses about its true structure, and you haven't shown the output you
want from this input. If there's another level of hierarchy that you need to
process between batchResponse and attr, then typically you just need to add
another template rule.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay   

-----Original Message-----
From: vinu shankar [mailto:vinuav_13(_at_)yahoo(_dot_)co(_dot_)in] 
Sent: 23 April 2010 09:31
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Re: Writing xslt from DSML

Thanks for suggesting me to use a XSLT editor.
I solved the errors.
I am able to get my required xml.
But one more thing Micheal, I want to transform multiple LDAP 
entries from the DSML file into the xml file.In order to do 
what is the modification to the existing code you gave me.(Is 
there any looping logic to be applied?) For example If my 
DSML input file is as follows(For example purpose I have just 
given 2 entries) <?xml version="1.0" encoding="UTF-8"?
<batchResponse xmlns:xsd="http://www.w3c.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance";
   <searchResponse
      <searchResultEntry
dn="uid=282002558871883,ou=People,o=sct.com,o=cp"
         <attr
name="uid"
           
<value282002558871883</value
         </attr
         <attr
name="pdsloginid"
           
<valuefac60006</value
         </attr
         <attr
name="givenname"
           
<valueBrutus</value
         </attr
         <attr
name="pdsemaildefaultaddress"
            <valuefac60006(_at_)sct(_dot_)com</value
         </attr
         <attr
name="pdscpsurveyed"
           
<valuetrue</value
         </attr
    </searchResultEntry
      <searchResultDone
         <resultCode
code="0" descr="success"/
      </searchResultDone
   </searchResponse
</batchResponse

<searchResultEntry
dn="uid=123456789,ou=People,o=sct.com,o=cp"
         <attr
name="uid"
           
<value123456789</value
         </attr
         <attr
name="pdsloginid"
           
<valuefac60007</value
         </attr
         <attr
name="givenname"
           
<valueBrutusad</value
         </attr
         <attr
name="pdsemaildefaultaddress"
            <valuefac60007(_at_)sct(_dot_)com</value
         </attr
         <attr
name="pdscpsurveyed"
           
<valuetrue</value
         </attr
    </searchResultEntry
      <searchResultDone
         <resultCode
code="0" descr="success"/
      </searchResultDone
   </searchResponse
</batchResponse




Date: Wed, 21 Apr 2010 11:45:24 +0100
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] Re: Writing xslt from DSML
Message-ID: <B57166A80C1644CDA52C49A58DC5227F(_at_)Sealion>

Looks like the mailer has inserted "3D" before all the "=3D" signs.

XSLT stylesheets have to be well-formed XML before you can 
get anywhere. = I suggest you use an XML editor that will 
help you resolve such problems.
You'll certainly have to get used to the fact that when you 
make typing mistakes in XSLT, you will get XML parsing errors.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay =20
--- On Wed, 21/4/10, vinu shankar <vinuav_13(_at_)yahoo(_dot_)co(_dot_)in 
wrote:

From: vinu shankar <vinuav_13(_at_)yahoo(_dot_)co(_dot_)in
Subject: Re: Writing xslt from DSML
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Wednesday, 21 April, 2010, 3:47 PM Hi Micheal,

Thank you very much for that reply.
I did not understand why you mentioned as two template rules.
I tried to Transform it using the Saxonica XSLT processor.
I am faced with the following error

Error on line 4 column 21 of pplStylesheet.xml:
  SXXP0003: Error reported by XML parser: Open quote is 
expected for attribute "
{1}"
  associated with an  element type
"match".
Failed to compile stylesheet. 1 error detected.


  The pplStylesheet.xml is the stylesheet you had
given me.

One more thing is I have to process an DSML file with
multiple entries.
What I had posted in my earlier post was just a
single
entry.
How do I process the multiple entry?
The DSML file format is as follows
<?xml version="1.0" encoding="UTF-8"?
<batchResponse xmlns:xsd="http://www.w3c.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance";
   <searchResponse
      <searchResultEntry
dn="uid=282002558871883,ou=People,o=sct.com,o=cp"
         <attr
name="uid"
           
<value282002558871883</value
         </attr
         <attr
name="pdsloginid"
           
<valuefac60006</value
         </attr
         <attr
name="givenname"
           
<valueBrutus</value
         </attr
         <attr
name="pdsemaildefaultaddress"
            <valuefac60006(_at_)sct(_dot_)com</value
         </attr
         <attr
name="pdscpsurveyed"
           
<valuetrue</value
         </attr
    </searchResultEntry
      <searchResultDone
         <resultCode
code="0" descr="success"/
      </searchResultDone
   </searchResponse
</batchResponse
  <searchResultEntry
dn="uid=123456789,ou=People,o=sct.com,o=cp"
         <attr
name="uid"
           
<value123456789</value
         </attr
         <attr
name="pdsloginid"
           
<valuefac60007</value
         </attr
         <attr
name="givenname"
           
<valueBrutusad</value
         </attr
         <attr
name="pdsemaildefaultaddress"
            <valuefac60007(_at_)sct(_dot_)com</value
         </attr
         <attr
name="pdscpsurveyed"
           
<valuetrue</value
         </attr
    </searchResultEntry
      <searchResultDone
         <resultCode
code="0" descr="success"/
      </searchResultDone
   </searchResponse
</batchResponse




Date: Tue, 20 Apr 2010 15:36:40 +0100
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com
Subject: RE: [xsl] Writing xslt from DSML
Message-ID:
<2D33B2DBC80C4A808427B9E292871994(_at_)Sealion

Looks like two template rules:

<xsl:template match=3D"batchResponse"
  <xsl:copy
    <xsl:apply-templates
select=3D".//attr"
  </xsl:copy
</xsl:template

<xsl:template match=3D"attr"
  <xsl:element name=3D"{(_at_)name}"
    <xsl:value-of select=3D"value"/
  </xsl:element
</xsl:template

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay=2

--- On Tue, 20/4/10, vinu shankar <vinuav_13(_at_)yahoo(_dot_)co(_dot_)in
wrote:

From: vinu shankar <vinuav_13(_at_)yahoo(_dot_)co(_dot_)in
Subject: Writing xslt from DSML
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Tuesday, 20 April, 2010, 6:50 PM
Hi,

I am using XSLT 2.0.
I have to form write the XSLT for the DSML
content
extracted from a LDAP server.
I am trying to generate an XML fragment from
multivalued
LDAP attributes. data(in DSML form) looks like

<batchResponse xmlns:xsd="http://www.w3c.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance";
   <searchResponse
      <searchResultEntry

dn="uid=282002558871883,ou=People,o=sct.com,o=cp"
         <attr name="uid"
           
<value282002558871883</value
         </attr
         <attr name="pdsloginid"
           
<valuefac60006</value
         </attr
         <attr name="givenname"
           
<valueBrutus</value
         </attr
         <attr
name="pdsemaildefaultaddress"
            <valuefac60006(_at_)sct(_dot_)com</value
         </attr
         <attr
name="pdscpsurveyed"
           
<valuetrue</value
         </attr
</searchResponse
</batchResponse

I need the XML file from the above DSML file.
The XML file which I need is
<batchResponse xmlns:xsd="http://www.w3c.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance";
    <uid
   
      282002558871883
    </uid
    <pdsloginid
        fac60006
    </pdsloginid
    <givenname
        Brutus
    </givenname
    <pdsemaildefaultaddress
        fac60006(_at_)sct(_dot_)com
    </pdsemaildefaultaddress
    <pdscpsurveyed
        true
    </pdscpsurveyed
</batchResponse
So how can I achieve this using XSLT.
I am a newbee to XSLT.Please help

Thank you,
Evergreen

















--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>