Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Tentatively... Sorry I haven't time to test that the following works...</p> <p><strong>EDIT</strong> (finishing after a long day at work...) <strong>Yes!</strong> That was about right. t'was only missing a * for the template match string, which should be "/*" not just "/" </p> <p>This tested ok with an XML file made by copying that from the OP's question (with necessary edits since the sample XML of the question is fragmentary). <strong>Attention, however!</strong> Using the *[local-name()='xyz'] trick to ignore namespaces should be kept for quick tests, read after the code snippet for a preferable way of handling these XML Namespaces.</p> <pre><code> &lt;xsl:template match="/"&gt; &lt;DIV STYLE="font-weight:bold"&gt; &lt;xsl:value-of select="*[local-name()='Task']/*[local-name()='MasterPerson']/*[local-name()='FName']" /&gt; &lt;/DIV&gt; &lt;/xsl:template&gt; </code></pre> <p><strong>XPath and Namespaces</strong></p> <p>The XPath data model treats an XML document as a tree of nodes, such as element, attribute, and text nodes, where the name of each node is a combination of its local name and its namespace name. Interestingly XPath deals with the default namespace in a way that is inconsistent, and that is why one doesn't notice all this xmlns issue until elements targeted by the XSL belong to fully qualified named elements in the input XML.... see this <a href="http://www.xml.com/pub/a/2004/02/25/qanda.html" rel="nofollow noreferrer">link</a> for more details.</p> <p>When faced with XML input that has xmlns-specified elements, an XSL script writer must either ensure to fully qualify its target nodes' names (preferred approach) or use the local-name() trick shown above to instruct XPath to ignore the namespaces. To use xmlns-prefixed names, a short prefix can be defined as usually and it can then be used by the XSL logic, as follows. (actual xmlns may be wrong, as the sample xml file is incomplete)</p> <pre><code>&lt;?xml version='1.0'?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.datacontract.org/2004/07/MCC.DAL"&gt; &lt;xsl:template match="/MyRoot"&gt; &lt;DIV STYLE="font-weight:bold"&gt; &lt;xsl:value-of select="t:Task/i:MasterPerson/i:FName" /&gt; &lt;/DIV&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload