problemer med parsning i java
Hej Eksperter.Min xsl ser sådan ud.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:udk="http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/" xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" xmlns:pie="http://rep.oio.dk/ubl/xml/schemas/0p71/pie/" xmlns:tpcm="http://rep.oio.dk/ubl/xml/schemas/0p71/testpcm/" xmlns:tpcp="http://rep.oio.dk/ubl/xml/schemas/0p71/testpcp/" xmlns:tpie="http://rep.oio.dk/ubl/xml/schemas/0p71/testpie/" xmlns:tpip="http://rep.oio.dk/ubl/xml/schemas/0p71/testpip/" xmlns:pip="http://rep.oio.dk/ubl/xml/schemas/0p71/pip/" xmlns:pcm="http://rep.oio.dk/ubl/xml/schemas/0p71/pcm/" xmlns:pcp="http://rep.oio.dk/ubl/xml/schemas/0p71/pcp/">
<xsl:output method="html" encoding="UTF-8" indent="yes" />
<xsl:variable name="fakturatype">
<xsl:choose>
<xsl:when test="contains(/pie:Invoice/com:TypeCode, 'PIE')">FAKTURA</xsl:when>
<xsl:when test="contains(/pip:Invoice/com:TypeCode, 'PIP')">FAKTURA</xsl:when>
<xsl:when test="contains(/pcm:Invoice/com:TypeCode, 'PCM')">KREDITNOTA</xsl:when>
<xsl:when test="contains(/pcp:Invoice/com:TypeCode, 'PCP')">KREDITNOTA</xsl:when>
<xsl:otherwise>Ukendt dokumenttype</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/">
<html>
<head>
<title>
</title>
</head>
<body>
OIOXML fakturavisning (<xsl:value-of select="/pie:Invoice/com:ID" />)
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Min xml ser således ud.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\obi\Desktop\testxsl\short.xsl"?>
<Invoice xmlns="http://rep.oio.dk/ubl/xml/schemas/0p71/pie/" xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" xmlns:main="http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rep.oio.dk/ubl/xml/schemas/0p71/pie/ http://rep.oio.dk/ubl/xml/schemas/0p71/pie/pielax.xsd">
<com:ID>0000638887</com:ID>
</Invoice>
Når jeg parser det i en browser virker det fint. Når jeg parser det i xmlspy virker det også fint men hvis jeg parser det med denne metode
private String transform(Source source, Reader xslReader)
throws Exception {
Transformer transformer;
TransformerFactory tFactory = TransformerFactory.newInstance();
transformer = tFactory.newTransformer(new StreamSource(xslReader));
Document xmlNew = null;
DOMResult domResult = new DOMResult();
transformer.transform(source, domResult);
xmlNew = (Document) domResult.getNode();
return XMLHelper.serialize(xmlNew);
}
Så får jeg ingen værdi trukket ud. Nogen der ved hvorfor?
