problem with xsl for multivalue strings

R

Rolf Barbakken

I have an xml with records like this one:

<a:response>
<a:href>http://server/public/sol/comp/1049306.eml</a:href>
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<d:customerid>1049306</d:customerid>
<e:professioncode b:dt="mv.string">
<c:v>byggtapetserarbeider</c:v>
<c:v>malerarbeider</c:v>
</e:professioncode>
</a:prop>
</a:propstat>
</a:response>

I want to display this tab-separated and have this xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:template
xmlns:a="DAV:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:"
match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:value-of select="a:propstat/a:prop/d:customerid"/>
<xsl:text> </xsl:text>
<xsl:for-each select="a:propstat/a:prop/f:professioncode/c:v">
<xsl:value-of select="concat(., ',')" />
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I have no problem getting the customerid, but without a "for-each" the
professioncode always comes out as a single string with no separation like
this:

byggtapetserarbeidermalerarbeider,

With the "for-each" I get this error:
msxml4.dll: Reference to undeclared namespace prefix: 'c'.

Where am I going wrong?
 
J

Joris Gillis

Hi,

Tempore 17:38:45 said:
With the "for-each" I get this error:
msxml4.dll: Reference to undeclared namespace prefix: 'c'.

Where am I going wrong?
The error message sais it all: you're trying to access an element "c:v" but you didn't declare the namespace that goes with "c". Just add the correct "xmlns:c" attribute to an ancestor-or-self of the "xsl:value-of" element.

regards,
 
R

Rolf Barbakken

Joris Gillis said:
Hi,

Tempore 17:38:45, die Thursday 28 July 2005 AD, hinc in foro

The error message sais it all: you're trying to access an element "c:v"
but you didn't declare the namespace that goes with "c". Just add the
correct "xmlns:c" attribute to an ancestor-or-self of the "xsl:value-of"
element.

I thought so too, so I tried

xmlns:c="c:"

and

<xsl:for-each select="a:propstat/a:prop/f:professioncode/c:v">
<xsl:value-of select="concat(., ',')"/>
</xsl:for-each>

Is this right?

With this code I get even less than before (no professioncodes at all), but
no error.
 
J

Joris Gillis

Tempore 20:54:06 said:
I thought so too, so I tried

xmlns:c="c:"

Obviously, the namespace-uri (between the quotes) has to be the same as the one declared in the source XML; it is not dummy data. "c:" is a very unlikely uri...


regards,
 
R

Rolf Barbakken

Joris Gillis said:
Tempore 20:54:06, die Thursday 28 July 2005 AD, hinc in foro


Obviously, the namespace-uri (between the quotes) has to be the same as
the one declared in the source XML; it is not dummy data. "c:" is a very
unlikely uri...

Well I've tried what looks like the correct namespace-uri:

xmlns:c="cln-ewa:standard:professioncode:"

and then:

<xsl:for-each select="a:propstat/a:prop/c:v">
<xsl:value-of select="concat(., ',')"/>
</xsl:for-each>

But nothing comes out of it (no professioncode). You can see the structure
in my xml in the OP.
 
J

Joris Gillis

Tempore 08:54:27 said:
xmlns:c="cln-ewa:standard:professioncode:"

and then:

<xsl:for-each select="a:propstat/a:prop/c:v">
<xsl:value-of select="concat(., ',')"/>
</xsl:for-each>

But nothing comes out of it (no professioncode).
That's pretty logical: there's no location step for 'professioncode'

INPUT XML:
<a:multistatus
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:">
<a:response>
<a:href>http://server/public/sol/comp/1049306.eml</a:href>
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<d:customerid>1049306</d:customerid>
<e:professioncode b:dt="mv.string">
<c:v>byggtapetserarbeider</c:v>
<c:v>malerarbeider</c:v>
</e:professioncode>
</a:prop>
</a:propstat>
</a:response>
</a:multistatus>

XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:template
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:"
match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:value-of select="a:propstat/a:prop/d:customerid"/>
<xsl:text> </xsl:text>
<xsl:for-each select="a:propstat/a:prop/e:professioncode/c:v">
<xsl:value-of select="concat(., ',')" />
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

OUTPUT :
1049306 byggtapetserarbeider,malerarbeider,


I only just thought about this: Do you need all data of type 'multivalue strings' to be seperated by comma's? If so, it's better to use a template:

<xsl:stylesheet version="1.0"
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:template

match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:value-of select="a:propstat/a:prop/d:customerid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:propstat/a:prop/e:professioncode"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>

<xsl:template match="*[@b:dt='mv.string']/*[position() !=last()]">
<xsl:value-of select="." /><xsl:text>,</xsl:text>
</xsl:template>

</xsl:stylesheet>

That will give you following output:
1049306 byggtapetserarbeider,malerarbeider




regards,
 
R

Rolf Barbakken

Joris Gillis said:
Tempore 08:54:27, die Friday 29 July 2005 AD, hinc in foro {comp.text.xml}

That's pretty logical: there's no location step for 'professioncode'

INPUT XML:
<a:multistatus
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:">
<a:response>
<a:href>http://server/public/sol/comp/1049306.eml</a:href>
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<d:customerid>1049306</d:customerid>
<e:professioncode b:dt="mv.string">
<c:v>byggtapetserarbeider</c:v>
<c:v>malerarbeider</c:v>
</e:professioncode>
</a:prop>
</a:propstat>
</a:response>
</a:multistatus>

XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:template
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:"
match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:value-of select="a:propstat/a:prop/d:customerid"/>
<xsl:text> </xsl:text>
<xsl:for-each select="a:propstat/a:prop/e:professioncode/c:v">
<xsl:value-of select="concat(., ',')" />
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

OUTPUT :
1049306 byggtapetserarbeider,malerarbeider,

I get no professioncode with this code.
I only just thought about this: Do you need all data of type 'multivalue
strings' to be seperated by comma's? If so, it's better to use a template:

<xsl:stylesheet version="1.0"
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:template

match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:value-of select="a:propstat/a:prop/d:customerid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:propstat/a:prop/e:professioncode"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>

<xsl:template match="*[@b:dt='mv.string']/*[position() !=last()]">
<xsl:value-of select="." /><xsl:text>,</xsl:text>
</xsl:template>

</xsl:stylesheet>

That will give you following output:
1049306 byggtapetserarbeider,malerarbeider

This returns absolutely nothing. Not one single byte of data. But no error.

The entire xsl now looks like this:
<xsl:stylesheet version="1.0"
xmlns:a="DAV:"
xmlns:b="unknown"
xmlns:c="cln-ewa:standard:professioncode:"
xmlns:d="urn:schemas:contacts:"
xmlns:e="cln-ewa:custom:"
xmlns:f="cln-ewa:standard:"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:template
match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:sn"/>
<xsl:text> </xsl:text>
<xsl:value-of select="translate(a:propstat/a:prop/d:street,
'
', ' ')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="translate(a:propstat/a:prop/d:postalcode,
'
', '')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:l"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:eek:fficetelephonenumber"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:telephoneNumber"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:mobile"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:email1"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:customerid"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:contacturl"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:facsimiletelephonenumber"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/a:creationdate"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:department"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:deleted"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:maker"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:work"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:ssn"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:visitadr"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:businesshomepage"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/e:agressoid"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/e:agressoinitials"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/d:homeState"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:contactikon"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:customergroup"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/e:contactperson"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:projects"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/e:agressonew"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/e:extagressoid"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/e:foretn"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:mycontact"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:activeprojects"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/f:contacted"/>
<xsl:text> </xsl:text>
<xsl:value-of select="a:propstat/a:prop/a:contentclass"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:propstat/a:prop/e:professioncode"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[@b:dt='mv.string']/*[position() !=last()]">
<xsl:value-of select="." /><xsl:text>,</xsl:text>
</xsl:template>
</xsl:stylesheet>

I really appreciate the help.
 
J

Joris Gillis

Tempore 18:44:06 said:
This returns absolutely nothing. Not one single byte of data. But no error.
I bet it's still a namespace issue.
Anyway, this conversation is leading nowhere. The XML sample in the OP was incomplete, I had to make to much assumptions.
Please provide the full XML (maybe a link to it?).

BTW, You don't need to copy everything I write litteraly;)
e.g. if I write xmlns:b="unknown" that means I do not posses enough information to make write the proper namespace-uri. You should have corrected it.

I hope we can soon fix this...
regards,
 
R

Rolf Barbakken

Joris Gillis said:
Tempore 18:44:06, die Friday 29 July 2005 AD, hinc in foro {comp.text.xml}

I bet it's still a namespace issue.
Anyway, this conversation is leading nowhere. The XML sample in the OP was
incomplete, I had to make to much assumptions.
Please provide the full XML (maybe a link to it?).

I have sent you an email. Hope the address is correct.
 
J

Joris Gillis

Tempore 22:04:55, die Friday 29 July 2005 AD, hinc in foro {comp.text.xml} scripsit Rolf Barbakken <[email protected]>:

Here's the sylesheet, it does not look very neat, but at least it works.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:f="cln-ewa:custom:"
xmlns:c="xml:"
xmlns:g="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:e="cln-ewa:standard:"
xmlns:d="urn:schemas:contacts:"
xmlns:a="DAV:">
<xsl:eek:utput method="text"/>
<xsl:template
match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:for-each select="(a:propstat/a:prop)[1]">
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:sn"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:street"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:postalcode"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:l"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:eek:fficetelephonenumber"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:telephoneNumber"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:mobile"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:email1"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:customerid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:contacturl"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:facsimiletelephonenumber"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:creationdate"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:department"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:deleted"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:maker"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:work"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:ssn"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:visitadr"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:businesshomepage"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:agressoid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:agressoinitials"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:homeState"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:contactikon"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:customergroup"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:contactperson"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:projects"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:agressonew"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:extagressoid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:foretn"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:mycontact"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:activeprojects"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:contacted"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:contentclass"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:professioncode"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

<xsl:template match="*[@b:dt='mv.string']/*[position() !=last()]">
<xsl:value-of select="." /><xsl:text>,</xsl:text>
</xsl:template>

<xsl:template match="d:street">
<xsl:value-of select="translate(., '
', ' ')" />
</xsl:template>

<xsl:template match="d:postalcode">
<xsl:value-of select="translate(., '
', '')" />
</xsl:template>

</xsl:stylesheet>

regards,
 
R

Rolf Barbakken

Joris Gillis said:
Tempore 22:04:55, die Friday 29 July 2005 AD, hinc in foro {comp.text.xml}
scripsit Rolf Barbakken <[email protected]>:

Here's the sylesheet, it does not look very neat, but at least it works.

How did you test it?

I get nothing out of this xsl-file. The XML fills up nicely, but when I do a

objXMLDOM.transformNode(objXSLDOM)

the result is nothing.

The XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:f="cln-ewa:custom:"
xmlns:c="xml:"
xmlns:g="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:e="cln-ewa:standard:"
xmlns:d="urn:schemas:contacts:"
xmlns:a="DAV:">
<xsl:eek:utput method="text"/>
<xsl:template
match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:for-each select="(a:propstat/a:prop)[1]">
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:sn"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:street"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:postalcode"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:l"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:eek:fficetelephonenumber"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:telephoneNumber"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:mobile"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:email1"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:customerid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:contacturl"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:facsimiletelephonenumber"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:creationdate"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:department"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:deleted"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:maker"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:work"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:ssn"/>
<xsl:text> </xsl:text>
<xsl:text></xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:visitadr"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:businesshomepage"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:agressoid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:agressoinitials"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="d:homeState"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:contactikon"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:customergroup"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:contactperson"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:projects"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:agressonew"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:extagressoid"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:foretn"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:mycontact"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:activeprojects"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="f:contacted"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="a:contentclass"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="e:professioncode"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[@b:dt='mv.string']/*[position() !=last()]">
<xsl:value-of select="." /><xsl:text>,</xsl:text>
</xsl:template>
<xsl:template match="d:street">
<xsl:value-of select="translate(., '
', ' ')" />
</xsl:template>
<xsl:template match="d:postalcode">
<xsl:value-of select="translate(., '
', '')" />
</xsl:template>
</xsl:stylesheet>
 
J

Joris Gillis

This one's nicer:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:f="cln-ewa:custom:"
xmlns:c="xml:"
xmlns:g="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:e="cln-ewa:standard:"
xmlns:d="urn:schemas:contacts:"
xmlns:a="DAV:">
<xsl:eek:utput method="text"/>

<xsl:variable name="field">
<xsl:text> d:sn d:street d:postalcode d:l d:eek:fficetelephonenumber d:telephoneNumber d:mobile d:email1 d:customerid f:contacturl d:facsimiletelephonenumber a:creationdate d:department f:deleted f:maker f:work f:ssn f:visitadr d:businesshomepage e:agressoid e:agressoinitials d:homeState f:contactikon f:customergroup e:contactperson f:projects e:agressonew e:extagressoid e:foretn f:mycontact f:activeprojects f:contacted a:contentclass e:professioncode</xsl:text>
</xsl:variable>

<xsl:template match="/">
<xsl:for-each select="a:multistatus/a:response">
<xsl:for-each select="(a:propstat/a:prop)[1]">
<xsl:call-template name="fieldCreator"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

<xsl:template name="fieldCreator">
<xsl:param name="fields" select="concat($field,' ')"/>
<xsl:apply-templates select="*[name()=substring-before($fields,' ')]"/>
<xsl:if test="substring-after($fields,' ')">
<xsl:text> </xsl:text>
<xsl:call-template name="fieldCreator">
<xsl:with-param name="fields" select="substring-after($fields,' ')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template match="*[@b:dt='mv.string']/*[position() !=last()]">
<xsl:value-of select="." /><xsl:text>,</xsl:text>
</xsl:template>

<xsl:template match="d:street">
<xsl:value-of select="translate(., '
', ' ')" />
</xsl:template>

<xsl:template match="d:postalcode">
<xsl:value-of select="translate(., '
', '')" />
</xsl:template>

</xsl:stylesheet>

P.S. Watch out for wrapping. The data of <xsl:variable name="field"/> should all be on 1 line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Parse XML document 1
Puzzling xsl problem 3
Namespace ins XSL 5
Problem with XSL 1
XSL Calculation 0
newbie problem with xml/xsl example 2
XML to CSV via XSL 1
[xsl] speed up tripple-muench 0

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top