Yaswanth, see below for some comments...
Yaswanth wrote:
Hi All,
I am facing a problem for counting ... because of namespaces.
---------------
I have my XML as ...
<?xml version="1.0" encoding="ISO-8859-1"?>
<sb:Signature xmi:version="2.0"
xmlns:cbe="http://www.readiminds.com/schema/cbe"
xmlns:sb="http://www.readiminds.com/infra/readione/workbench/signaturebuilde
r" xmlns:xmi="http://www.omg.org/XMI">
<every>
<every>
<event alias="Event1" name="FraudEvent"/>
</every>
<every>
<event alias="Event1" name="FraudEvent"/>
</every>
</every>
<every>
</every>
</sb:Signature>
----------------
And in my XSL
I want to count how many every's are there under <sb:Signature>
<xsl:variable name="cevery" select="count(//sb:Signature/every)"/>
I recommend using count(/sb:Signature.every) instead. sb:Signature is at
your root, no reason to ask for the processor to search through every
level at every depth (which is what // does) of the tree for a possible
sb:Signature.
If you define "under sb:Signature" as under that nod at any depth, you
have to put the // elsewhere, like this: count(/sb:Signature//every).
Now, since we know that sb:Signature is at the root level and since we
know that a document can only have one root element (I know, this is not
entirely true, for the sake of this discussion it suffices), we can
change this requirement to: count(//every), which will count every node
in your document.
As a result, you do not need to bind the prefix anymore because you are
not searching for elements that are inside a namespace (you do not
declare a default namespace in your snippet above).
This is not working .. It says prefix should resolve to name space !!
this has already been answered by David ;) but now it is not needed
anymore (but of course, good practice learns us that it is best to copy
the namespaces we have in the source(s) to the XSLT we are making.
Cheers,
-- Abel Braaksma
--~------------------------------------------------------------------
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>
--~--