XSLTPROC parser error

fdeltesta
Contributor

Hello,

 

I'm trying to fetch some informations about a given device with thhe API and I can't get it to work, can someone enlight me ?

Here's my stylesheet definition:

cat << EOF > /tmp/computer.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
	<xsl:for-each select="computer/general">
		<xsl:value-of select="name"/>
		<xsl:text>,</xsl:text>
		<xsl:value-of select="serial_number"/>
		<xsl:text>,</xsl:text>
		<xsl:value-of select="site/name"/>
		<xsl:text>&#xa;</xsl:text>
	</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
EOF

 

And here's how I run it:

fetchDetails=$(curl -sk 'authorization: Basic HIDDEN' -H "Accept: application/xml" https://HIDDEN/JSSResource/computers/id/$jamfID | xsltproc /tmp/computer.xslt -)
echo "$fetchDetails"

 

And however I try to tweak and change I always receive an epty output from my echo, and these as error message from the API call:

-:10: parser error : Opening and ending tag mismatch: br line 8 and p
</p>
    ^
-:11: parser error : Opening and ending tag mismatch: p line 8 and body
</body>
       ^
-:12: parser error : Opening and ending tag mismatch: body line 5 and html
</html>
       ^
-:12: parser error : Premature end of data in tag html line 1
</html>
       ^
unable to parse -

 

It's already not helping because the errors are not directly linked to my stylesheet, but that "unable to parse -" is a real mystery.

 

Thanks in advance.

1 ACCEPTED SOLUTION

ljcacioppo
Contributor III

I think you need a -H in front of your base64 authentication since that is a header. Can you try this:

fetchDetails=$(curl -sk -H 'authorization: Basic HIDDEN' -H "Accept: application/xml" https://HIDDEN/JSSResource/computers/id/$jamfID | xsltproc /tmp/computer.xslt -)
echo "$fetchDetails"

View solution in original post

2 REPLIES 2

ljcacioppo
Contributor III

I think you need a -H in front of your base64 authentication since that is a header. Can you try this:

fetchDetails=$(curl -sk -H 'authorization: Basic HIDDEN' -H "Accept: application/xml" https://HIDDEN/JSSResource/computers/id/$jamfID | xsltproc /tmp/computer.xslt -)
echo "$fetchDetails"

Man I feel so stupid.

It worked, thank you so much ! Kinda mad I didn't ask for this earlier, I lost a few hours on this...

Though now I'll remember each header needs its " -H ".