DOM2SAX doesn't come from Xerces. You may want to ask this question on the 
xml-security list or one of the Xalan lists.

hudzia <[EMAIL PROTECTED]> wrote on 08/31/2005 10:53:43 PM:

> Hi , i?m trying to include a DOM document inside a XML  file through
> a SAX parser ( let just say that one part of the document is binary 
> , so using DOM would consume too much memory ) .
> 
> I?m force to generate part of the document as a DOM because I use 
> XML-SEC from apache project , and it generate a DOM document.
> 
> I need to include this DOM inside an XML file . I used DOM2SAX to do
> the trick ? but I got a strange behaviour : 
> 
> It add a end of line charater after adding/ parsing the dom to sax 
> here is a part of the resulting XML file  : 
> 
> 
> <MetaInfo>
> ?
> ?
> ?
> 
> </KeyData>
> <InfoData>
> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#";>
> <ds:SignedInfo>
> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-
> xml-c14n-20010315"/>
> <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-
> more#rsa-sha512"/>
> <ds:Reference URI="#InfoData">
> <ds:Transforms>
> <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-
> c14n-20010315#WithComments"/>
> </ds:Transforms>
> <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
> <ds:DigestValue>krNGKj9lCg4musg2JU8BUJzT24w=</ds:DigestValue>
> </ds:Reference>
> </ds:SignedInfo>
> <ds:SignatureValue>
> 
uqKGx8UwHWLaBzXE6923TGLTgKNbRlqq56huixJjNqXRiVzcE4t2gnd4wSiO8ooyeStfQAd1dSyn
> 
QvnpyUBoEW9e1emAQmjeu3bSS4aJ1iqlUGJLM+2JS86Dp/66UDoGdICfwwTmj3k/foPPRgv1fzc5
> xAyNRQ74N5aPWxDbKGI=
> </ds:SignatureValue>
> <ds:KeyInfo>
> <ds:KeyValue>
> <ds:RSAKeyValue>
> <ds:Modulus>
> 
2uFgcoflfPrdi3OI/xRmZlkfqbpuV99ADGmZ6O9bDGX0KdTRtd4EKxckxowaYWMDC7GF7zuA30dg
> 
VjAleObbbCMJJK6oIWmwQQ8aBVCSvaoiaEl6Ix8GIyzBsHJ01HEW2gyv89VLM8XfRUdZyNEsCp4n
> QS5+oIofoHD6M3De58c=
> </ds:Modulus>
> <ds:Exponent>AQAB</ds:Exponent>
> </ds:RSAKeyValue>
> </ds:KeyValue>
> <ds:X509Data>
> <ds:X509Certificate>
> 
MIIB+jCCAWOgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBDMQswCQYDVQQGEwJGUjEYMBYGA1UEChMP
> 
VGhlIG1pZ2h0eSBCTE9QMRowGAYDVQQLExFCbG9wIHByaW1hcnkgY2VydDAeFw0wNTA3MjcxNDI0
> 
NDVaFw0wNTA5MjUxNDI0NDVaMEMxCzAJBgNVBAYTAkZSMRgwFgYDVQQKEw9UaGUgbWlnaHR5IEJM
> 
T1AxGjAYBgNVBAsTEUJsb3AgcHJpbWFyeSBjZXJ0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
> 
gQDa4WByh+V8+t2Lc4j/FGZmWR+pum5X30AMaZno71sMZfQp1NG13gQrFyTGjBphYwMLsYXvO4Df
> 
R2BWMCV45ttsIwkkrqghabBBDxoFUJK9qiJoSXojHwYjLMGwcnTUcRbaDK/z1Uszxd9FR1nI0SwK
> 
nidBLn6gih+gcPozcN7nxwIDAQABMA0GCSqGSIb3DQEBDQUAA4GBALagkndac1gI+7UGLIzsU2N6
> 
i73CSdxFxWGR1p1THQ1C+/EY2KGVsHYxkNb6xDsaVIJr0QzSrRO+XA3jwa2IvMNEDI5k2f4xPGKG
> rniKhRcrsJUwhBa1aM+2VAkaz8G6ZUrwwyaQDvChVwjyyqpjCBJhKmaR9x9Hr200Jl6Vj+g6
> </ds:X509Certificate>
> </ds:X509Data>
> </ds:KeyInfo>
> <ds:Object Id="InfoData">
> <blopblop>blop blop blpob  blpob lbpob lbop</blopblop>
> <Assets>
> <Asset>
> 
<AssetUID>vhUelSvYCuDRXzwLW1gjQaLkAL8dmOPmY1SvsBVHa9/xjG35L7qh+Itz29UW0JOGm+Oo5TsH1xMt
> L2YAawaW/w==</AssetUID>
> <AssetName>\id.p12</AssetName>
> <AssetPath></AssetPath>
> </Asset>
> </Assets>
> </ds:Object>
> </ds:Signature>
> 
> </InfoData>
> </MetaInfo>
> 
> 
> Just after the </ds:Signature> and before  </InfoData>
> 
> Here the code : 
> StreamResult result = new StreamResult(fos);
> 
>                         SAXTransformerFactory tf = 
> (SAXTransformerFactory) SAXTransformerFactory
>                                                .newInstance();
>                         TransformerHandler th = null;
>                         try {
>                                    th = tf.newTransformerHandler();
>                         } catch (TransformerConfigurationException e2) {
>                                    logger
>                                                            .fatal(" 
> problem creating the transform : "
> 
> + e2.getMessage());
> 
>                         }
>                         Transformer serializer = th.getTransformer();
> 
>                         serializer.setOutputProperty(OutputKeys.
> ENCODING, "UTF-8");
>                          serializer.setOutputProperty(OutputKeys.
> INDENT, "yes");
> 
>                         th.setResult(result);
> 
>                         try {
>                                    th.startDocument();
> 
> ?
> ?
> Code ?
> ?
> ?
> 
> 
> DOM2SAX dom2SaxKey = new DOM2SAX(keyDataDoc);
>                                    DOM2SAX dom2SaxInfo = new 
> DOM2SAX(infoDataDoc);
> 
>                                    dom2SaxKey.setContentHandler(th);
>                                    dom2SaxInfo.setContentHandler(th);
> 
>                                    atts.clear();
>                                    th.startElement("", "", "KeyData", 
atts);
> 
>                                    dom2SaxKey.parse();
>                                    th.endElement("", "", "KeyData");
>                                    th.startElement("", "", "InfoData", 
atts);
>                                    dom2SaxInfo.parse();
>                                    th.endElement("", "", "InfoData");
> 
>                                    th.endElement("", "", "MetaInfo");
> 
>                                    th.endDocument();
> 
> 
> I still don?t understand why this end of line character appears 
> twice ( twice, for each signed DOM added ) , anyone can help me ?? 
> 
> 
> Thanks 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to