XML Transformation

I

Iain

Hi,

I am trying to transform a XML document using a XSL document.

One of my attributes is called RECORDS which needs to contain a value of
how many records are in the data feed so my database package knows how
many records it needs to import, the way to return this number I thought
would be to count an attribute which only appears once, so I added the
following element <xsl:value-of select="count(//Client/@WorkCode)"/> but
it always returns 0.

Does anybody know a way to do this as what I am doing must be wrong.

TIA
 
D

David Carlisle

Iain said:
Hi,

I am trying to transform a XML document using a XSL document.

One of my attributes is called RECORDS which needs to contain a value of
how many records are in the data feed so my database package knows how
many records it needs to import, the way to return this number I thought
would be to count an attribute which only appears once, so I added the
following element <xsl:value-of select="count(//Client/@WorkCode)"/> but
it always returns 0.

Does anybody know a way to do this as what I am doing must be wrong.

TIA


The code you post is legal XSLT and XPath and counts the number of
WorkCode attributes of a Client elements in the document in which the
current node is located.

If the value returned is 0 then short of any other evidence the most
likely reason is that there are no such attributes.

Perhaps your Client elements are in a namespace (The Xpath shown looks
for elements in no-namespace) or the current node is not in the document
that you expect, or ....

David
 
I

Iain

David said:
The code you post is legal XSLT and XPath and counts the number of
WorkCode attributes of a Client elements in the document in which the
current node is located.

If the value returned is 0 then short of any other evidence the most
likely reason is that there are no such attributes.

Perhaps your Client elements are in a namespace (The Xpath shown looks
for elements in no-namespace) or the current node is not in the document
that you expect, or ....

David

I took out the namespace in the source xml document and my XSLT returned
the number of records, how would I get the Xpath to look for the element
in a namespace?
 
D

David Carlisle

FFFFAQ:)
see for example the xsl faq at www.dpawson.co.uk

You need to declare a (any) prefix for the namespace in your stylesheet
(usually on the xsl:stylesheet element) xmlns:x="lkjlhgkfg" then to
refer to elements in that namespace use x:Client etc.

David
 

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

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top