how to import attributes in fmpxmlresult?

I try import atributes amd… bad resutl i only need value of atribute : NSU="000000000000551 …552…553 thanks for your help myxslt

<?xml version='1.0' encoding='UTF-8' ?> <xsl:stylesheet version="1.0"  xmlns:xsl="" xmlns:a="">   <xsl:template match="/">     <FMPXMLRESULT xmlns="">         <METADATA>             <FIELD NAME="nNsu" TYPE="TEXT"/>         </METADATA>             <RESULTSET>                 <xsl:for-each select="/a:retDistDFeInt/a:loteDistDFeInt/a:docZip">                     <ROW>                         <COL><DATA><xsl:value-of select="a:retDistDFeInt/a:loteDistDFeInt/a:docZip/@nsu"/></DATA></COL>                     </ROW>                 </xsl:for-each>             </RESULTSET>     </FMPXMLRESULT> </xsl:template> 


Original xml

<?xml version="1.0"?> <retDistDFeInt xmlns="" versao="1.00"  xmlns:xsi=""  xmlns:xsd="">  <tpAmb>1</tpAmb>  <verAplic>1.2.0</verAplic>  <cStat>138</cStat>  <xMotivo>Documento(s) localizado(s)</xMotivo>  <dhResp>2020-06-28T09:11:29</dhResp>  <ultNSU>000000000000557</ultNSU>  <maxNSU>000000000000557</maxNSU>    <loteDistDFeInt>     <docZip schema="procNFe_v4.00.xsd" N              NSU="000000000000551">H4sIAAAAAAAEAK1Z6ZOrOJL</docZip>     <docZip schema="procNFe_v4.00.xsd"             NSU="000000000000552">H4sIAAAAAAAEAK1Z6ZOrOJL</docZip>     <docZip schema="procNFe_v4.00.xsd"             NSU="000000000000553">H4sIAAAAAAAEAK1Z6ZOrOJL</docZip> <loteDistDFeInt> </retDistDFeInt> 
Add Comment
1 Answer(s)

There are two problems with your stylesheet:

  1. When you do:

    <xsl:for-each select="/a:retDistDFeInt/a:loteDistDFeInt/a:docZip"> 

    you are put in the context of docZip. From this context, the instruction:

    <xsl:value-of select="a:retDistDFeInt/a:loteDistDFeInt/a:docZip/@nsu"/> 

    selects nothing, because docZip does not have a retDistDFeInt child. You need to use a relative path to the attribute you want.

  2. XML is case-sensitive: @nsu will not select an attribute whose name is NSU.

To put it together, if you change:

<xsl:value-of select="a:retDistDFeInt/a:loteDistDFeInt/a:docZip/@nsu"/> 


<xsl:value-of select="@NSU"/> 

you should get the expected result.

Answered on July 17, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.