You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by mauro castelli <ca...@hotmail.com> on 2006/06/13 23:29:31 UTC
Programmatically create XML 1.1 Document
hi all,
I'm using the latest version of Xalan/Xerces in order to achieve xml 1.1
support.
Looking at the "Samples" to get ideas on how to programmatically create
an XML Document in memory: xerces/CreateDOMDocument (DOM) and
xalan/DocumentBuilder(SAX).
Here is the question:
How can I specify, both with xerces-DOM and xalan-SAX, that I want to use
XML 1.1
instead of the default XML 1.0?
If I then want to apply an XSL Transform, should I take care of something
special due to
the 1.1 version?
Thanks and Regards,
Mauro Castelli.
_________________________________________________________________
Prova subito il nuovo Windows Live Messenger Beta
http://imagine-msn.com/messenger/launch80/?locale=it-it
_________________________________________________________________
Personalizza MSN Messenger con sfondi e fotografie!
http://www.ilovemessenger.msn.it/
Re: ICU version on .NET2005 with Xalan 1.10.0
Posted by David Bertoni <db...@apache.org>.
mauro castelli wrote:
> Hi all,
> in order achieve support for "format-number" Xalan (release 1.10.0)
> must be integrated with ICU 3.2.
>
> I'm working with Microsoft Visual Studio .NET 2005 and the ICU web page
> (http://xml.apache.org/xalan-c/usagepatterns.html#icu) suggests to download
> the ICU last release (3.4.1) for that development environment.
> Which ICU release do you suggest? I'd prefer the ICU 3.4.1, but I'd like
> to know whether
> there are any known compatibility issues with Xalan1.10.0/Xerces2.7.0
I don't believe it's been tested. The latest I've used is ICU 3.2, but we don't often have compatibility issues, so you
may want to just give it a shot and see what happens.
Dave
ICU version on .NET2005 with Xalan 1.10.0
Posted by mauro castelli <ca...@hotmail.com>.
Hi all,
in order achieve support for "format-number" Xalan (release 1.10.0)
must be integrated with ICU 3.2.
I'm working with Microsoft Visual Studio .NET 2005 and the ICU web page
(http://xml.apache.org/xalan-c/usagepatterns.html#icu) suggests to download
the ICU last release (3.4.1) for that development environment.
Which ICU release do you suggest? I'd prefer the ICU 3.4.1, but I'd like to
know whether
there are any known compatibility issues with Xalan1.10.0/Xerces2.7.0
Thanks and Regards,
Mauro Castelli.
_________________________________________________________________
Personalizza MSN Messenger con sfondi e fotografie!
http://www.ilovemessenger.msn.it/
Re: Programmatically create XML 1.1 Document
Posted by mauro castelli <ca...@hotmail.com>.
Great David !
All is working fine now.
Thanks a lot,
Mauro.
(Naturally , I'll make you know if I have some other little problem in
future...;-)
----Original Message Follows----
From: David Bertoni <db...@apache.org>
Reply-To: xalan-c-users@xml.apache.org
To: xalan-c-users@xml.apache.org
Subject: Re: Programmatically create XML 1.1 Document
Date: Fri, 16 Jun 2006 09:22:27 -0700
mauro castelli wrote:
>David,
>thank you very much for your precious hints and sorry if my question was
>not clear.
>
>>I don't know what "xalan-SAX" is. Can you be more specific? If you mean
>>using the class >"XalanDocumentBuilder," then you can send events that
>>contains Unicode characters that would be illegal in XML 1.0, but legal in
>>XML 1.1.
>Yes, I meant "using XalanDocumentBuilder" and you hit the centre of the
>question.
>I tried to introduce a single Unicode control character in the
>DocumentBuilder sample
>in this way:
> [...]
> theAttributes.clear();
> theAttributeName = XALAN_STATIC_UCODE_STRING("attribute2");
> // I replaced the string "value2" with ""
> theAttributeValue = XALAN_STATIC_UCODE_STRING("");
> theAttributes.addAttribute(c_wstr(theAttributeName),
>c_wstr(theAttributeType), c_wstr(theAttributeValue));
> [...]
>
This adds an attribute with a value that has 7 characters: "&" "#" "x" "0"
"0" "4" ";". This is not what you wanted, I expect.
You probably want to do something like this:
const XalanDOMChar val[] = { 4, 0 };
theAttributes.addAttribute(
theAttributeName.c_wstr(),
theAttributeType.c_wstr(),
val);
You are assuming that if you create an attribute value that looks like a
numeric character reference, that you'll get the character specified, but
you won't.
>Applying a xslt such as
> <?xml version="1.1" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>version="1.0">
> <xsl:output version="1.1"/>
> <xsl:template match="node() | @*">
> <xsl:copy>
> <xsl:apply-templates select="node() | @*"/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
>the output presents attribute2 with a string valued as "&#x004;"
>instead of the corresponding control character.
>The same behaviour if I use "�" even if I would expect an error, since
>that
>is the only unsupported unicode control character in XML 1.1.
That is the expected result, since the value of the attribute is the not the
character U+0004.
You should be very careful doing this sort of thing. Xalan-C expects that
the source tree you give it has been properly constructed. That means it
cannot contain any invalid characters for the version of XML you mean to
support.
Dave
_________________________________________________________________
Ti senti più Totti o Kakà? http://mondiali.it.msn.com/messengercup2006/
Re: Programmatically create XML 1.1 Document
Posted by David Bertoni <db...@apache.org>.
mauro castelli wrote:
> David,
> thank you very much for your precious hints and sorry if my question was
> not clear.
>
>> I don't know what "xalan-SAX" is. Can you be more specific? If you mean
>> using the class >"XalanDocumentBuilder," then you can send events that
>> contains Unicode characters that would be illegal in XML 1.0, but
>> legal in
>> XML 1.1.
> Yes, I meant "using XalanDocumentBuilder" and you hit the centre of the
> question.
> I tried to introduce a single Unicode control character in the
> DocumentBuilder sample
> in this way:
> [...]
> theAttributes.clear();
> theAttributeName = XALAN_STATIC_UCODE_STRING("attribute2");
> // I replaced the string "value2" with ""
> theAttributeValue = XALAN_STATIC_UCODE_STRING("");
> theAttributes.addAttribute(c_wstr(theAttributeName),
> c_wstr(theAttributeType), c_wstr(theAttributeValue));
> [...]
>
This adds an attribute with a value that has 7 characters: "&" "#" "x"
"0" "0" "4" ";". This is not what you wanted, I expect.
You probably want to do something like this:
const XalanDOMChar val[] = { 4, 0 };
theAttributes.addAttribute(
theAttributeName.c_wstr(),
theAttributeType.c_wstr(),
val);
You are assuming that if you create an attribute value that looks like a
numeric character reference, that you'll get the character specified,
but you won't.
> Applying a xslt such as
> <?xml version="1.1" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output version="1.1"/>
> <xsl:template match="node() | @*">
> <xsl:copy>
> <xsl:apply-templates select="node() | @*"/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
> the output presents attribute2 with a string valued as "&#x004;"
> instead of the corresponding control character.
> The same behaviour if I use "�" even if I would expect an error,
> since that
> is the only unsupported unicode control character in XML 1.1.
That is the expected result, since the value of the attribute is the not
the character U+0004.
You should be very careful doing this sort of thing. Xalan-C expects
that the source tree you give it has been properly constructed. That
means it cannot contain any invalid characters for the version of XML
you mean to support.
Dave
Re: Programmatically create XML 1.1 Document
Posted by mauro castelli <ca...@hotmail.com>.
David,
thank you very much for your precious hints and sorry if my question was not
clear.
>I don't know what "xalan-SAX" is. Can you be more specific? If you mean
>using the class >"XalanDocumentBuilder," then you can send events that
>contains Unicode characters that would be illegal in XML 1.0, but legal in
>XML 1.1.
Yes, I meant "using XalanDocumentBuilder" and you hit the centre of the
question.
I tried to introduce a single Unicode control character in the
DocumentBuilder sample
in this way:
[...]
theAttributes.clear();
theAttributeName = XALAN_STATIC_UCODE_STRING("attribute2");
// I replaced the string "value2" with ""
theAttributeValue = XALAN_STATIC_UCODE_STRING("");
theAttributes.addAttribute(c_wstr(theAttributeName),
c_wstr(theAttributeType), c_wstr(theAttributeValue));
[...]
Applying a xslt such as
<?xml version="1.1" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output version="1.1"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
the output presents attribute2 with a string valued as "&#x004;"
instead of the corresponding control character.
The same behaviour if I use "�" even if I would expect an error, since
that
is the only unsupported unicode control character in XML 1.1.
Any suggestions/comments would be very appreciated.
Thanks,
Mauro.
----Original Message Follows----
From: David Bertoni <db...@apache.org>
Reply-To: xalan-c-users@xml.apache.org
To: xalan-c-users@xml.apache.org
Subject: Re: Programmatically create XML 1.1 Document
Date: Wed, 14 Jun 2006 17:31:03 -0700
mauro castelli wrote:
>hi all,
>I'm using the latest version of Xalan/Xerces in order to achieve xml 1.1
>support.
>Looking at the "Samples" to get ideas on how to programmatically create
>an XML Document in memory: xerces/CreateDOMDocument (DOM) and
>xalan/DocumentBuilder(SAX).
>
You'll have to ask the Xerces-specific questions on the Xerces-C user list.
>Here is the question:
>How can I specify, both with xerces-DOM and xalan-SAX, that I want to use
>XML 1.1
>instead of the default XML 1.0?
I don't know what "xalan-SAX" is. Can you be more specific? If you mean
using the class "XalanDocumentBuilder," then you can send events that
contains Unicode characters that would be illegal in XML 1.0, but legal in
XML 1.1.
>If I then want to apply an XSL Transform, should I take care of something
>special due to
>the 1.1 version?
Your stylesheet will need an xsl:output element with a version attribute
with the value "1.1".
Note that XML 1.1 support in Xalan-C is still experimental, so you may
experience problems. Also, there is no support for "undeclaring"
namespaces, so you won't be able to use that feature of XML Namespaces 1.1.
Dave
_________________________________________________________________
Scarica gratuitamente MSN Toolbar! http://toolbar.msn.it/
Re: Programmatically create XML 1.1 Document
Posted by David Bertoni <db...@apache.org>.
mauro castelli wrote:
> hi all,
> I'm using the latest version of Xalan/Xerces in order to achieve xml 1.1
> support.
> Looking at the "Samples" to get ideas on how to programmatically create
> an XML Document in memory: xerces/CreateDOMDocument (DOM) and
> xalan/DocumentBuilder(SAX).
>
You'll have to ask the Xerces-specific questions on the Xerces-C user list.
> Here is the question:
> How can I specify, both with xerces-DOM and xalan-SAX, that I want to
> use XML 1.1
> instead of the default XML 1.0?
I don't know what "xalan-SAX" is. Can you be more specific? If you
mean using the class "XalanDocumentBuilder," then you can send events
that contains Unicode characters that would be illegal in XML 1.0, but
legal in XML 1.1.
> If I then want to apply an XSL Transform, should I take care of
> something special due to
> the 1.1 version?
Your stylesheet will need an xsl:output element with a version attribute
with the value "1.1".
Note that XML 1.1 support in Xalan-C is still experimental, so you may
experience problems. Also, there is no support for "undeclaring"
namespaces, so you won't be able to use that feature of XML Namespaces 1.1.
Dave