From: Oleg T. <he...@us...> - 2004-10-14 13:47:18
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22558/v1/src Modified Files: SR.cs SR.resx TextIncludingReader.cs XIncludeException.cs XIncludingReader.cs Log Message: Externalized strings. Index: XIncludeException.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludeException.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XIncludeException.cs 29 Sep 2004 21:26:28 -0000 1.2 +++ XIncludeException.cs 14 Oct 2004 13:47:07 -0000 1.3 @@ -50,10 +50,9 @@ /// </summary> public class UnknownParseAttributeValueException : FatalException { public UnknownParseAttributeValueException(string attrValue) : - base("Unknown 'parse' attribute value: '" + attrValue + "'.") {} + base(SR.GetString("UnknownParseAttrValue", attrValue)) {} public UnknownParseAttributeValueException(string attrValue, string uri, int line, int position) : - base("Unknown 'parse' attribute value: '" + attrValue + "'." - + uri + ", Line " + line + ", Position " + position) {} + base(SR.GetString("UnknownParseAttrValueLong", attrValue, uri, line, position)) {} } /// <summary> @@ -61,7 +60,7 @@ /// </summary> public class NonXmlCharacterException : FatalException { public NonXmlCharacterException(char c) : - base("Included document contains forbidden in XML character: 0x"+ ((int)c).ToString("X2")) {} + base(SR.GetString("NonXmlCharacter", ((int)c).ToString("X2"))) {} } /// <summary> @@ -69,10 +68,9 @@ /// </summary> public class CircularInclusionException : FatalException { public CircularInclusionException(Uri uri) : - base("Circular inclusion has been detected, inclusion location: " + uri.AbsoluteUri) {} + base(SR.GetString("CircularInclusion", uri.AbsoluteUri)) {} public CircularInclusionException(Uri uri, string locationUri, int line, int position) : - base("Circular inclusion has been detected, inclusion location: " + uri.AbsoluteUri + "." - + locationUri + ", Line " + line + ", Position " + position) {} + base(SR.GetString("CircularInclusionLong", uri.AbsoluteUri, locationUri, line, position)) {} } /// <summary> @@ -80,7 +78,7 @@ /// </summary> public class FatalResourceException : FatalException { public FatalResourceException(Exception re) : - base("Resource error has occured and no fallback has been provided: " + re.Message, re) {} + base(SR.GetString("FatalResourceException", re.Message), re) {} } /// <summary> Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- XIncludingReader.cs 13 Oct 2004 17:46:59 -0000 1.6 +++ XIncludingReader.cs 14 Oct 2004 13:47:07 -0000 1.7 @@ -553,7 +553,7 @@ if (_topLevel && _reader.NodeType == XmlNodeType.Attribute) { //Attempt to include an attribute - throw new AttributeOrNamespaceInIncludeLocationError("Include location identifies an attribute or namespace node!"); + throw new AttributeOrNamespaceInIncludeLocationError(SR.AttributeOrNamespaceInIncludeLocationError); } switch (_reader.NodeType) { @@ -600,11 +600,15 @@ IXmlLineInfo li = _reader as IXmlLineInfo; if (li != null && li.HasLineInfo()) { - throw new SyntaxError("xi:fallback element must be direct child of xi:include element." - + _reader.BaseURI.ToString() + ", Line " + li.LineNumber + ", Position " + li.LinePosition); + throw new SyntaxError( + SR.GetString("FallbackNotChildOfIncludeLong", + _reader.BaseURI.ToString(), li.LineNumber, + li.LinePosition)); } else - throw new SyntaxError("xi:fallback element must be direct child of xi:include element." + _reader.BaseURI.ToString()); + throw new SyntaxError( + SR.GetString("FallbackNotChildOfInclude", + _reader.BaseURI.ToString())); } else goto default; @@ -733,11 +737,11 @@ } catch (NotSupportedException nse) { - throw new ResourceException("URI schema is not supported: '" + href + "'", nse); + throw new ResourceException(SR.GetString("URISchemaNotSupported", href), nse); } catch (SecurityException se) { - throw new ResourceException("Security exception while fetching '" + href + "'", se); + throw new ResourceException(SR.GetString("SecurityException", href), se); } //Add accept headers if this is HTTP request HttpWebRequest httpReq = wReq as HttpWebRequest; @@ -752,6 +756,7 @@ } if (acceptLanguage != null) { + //TODO: WTF??? httpReq.Headers.Add("Accept-Language", "ru"); if (httpReq.Headers["Accept-Language"] == null) httpReq.Headers.Add("Accept-Language", acceptLanguage); @@ -765,7 +770,7 @@ } catch (WebException we) { - throw new ResourceException("Resource '" + href + "' cannot be fetched", we); + throw new ResourceException(SR.GetString("ResourceError", href), we); } return response.GetResponseStream(); } @@ -785,16 +790,20 @@ IXmlLineInfo li = _reader as IXmlLineInfo; if (li != null && li.HasLineInfo()) { - throw new MissingHrefAndXpointerException("'href' or 'xpointer' attribute is required on xi:include element. " - + _reader.BaseURI.ToString() + ", Line " + li.LineNumber + ", Position " + li.LinePosition); + throw new MissingHrefAndXpointerException( + SR.GetString("MissingHrefAndXpointerExceptionLong", + _reader.BaseURI.ToString(), + li.LineNumber, li.LinePosition)); } else - throw new MissingHrefAndXpointerException("'href' or 'xpointer' attribute is required on xi:include element. " + _reader.BaseURI.ToString()); + throw new MissingHrefAndXpointerException( + SR.GetString("MissingHrefAndXpointerException", + _reader.BaseURI.ToString())); } else { //No href - intra-document reference - throw new NotImplementedException("Intra-document references are not implemented yet!"); + throw new NotImplementedException(SR.IntradocumentReferencesNotSupported); } } string parse = _reader.GetAttribute(_keywords.Parse); @@ -836,10 +845,10 @@ } catch (Exception e) { - throw new ResourceException("An exception has occured during GetEntity call to custom XmlResolver", e); + throw new ResourceException(SR.CustomXmlResolverError, e); } if (resource == null) - throw new ResourceException("Custom XmlResolver returned null"); + throw new ResourceException(SR.CustomXmlResolverReturnedNull); //Ok, we accept Stream and XmlReader only XmlReader r; if (resource is Stream) @@ -848,7 +857,9 @@ r = (XmlReader)resource; else //Unsupported type - throw new ResourceException("Custom XmlResolver returned object of unsupported type."); + throw new ResourceException(SR.GetString( + "CustomXmlResolverReturnedUnsupportedType", + resource.GetType().ToString())); //Push new base URI to the stack _baseURIs.Push(includeLocation); //Push current reader to the stack @@ -907,11 +918,11 @@ } catch(UriFormatException ufe) { - throw new ResourceException("Invalid URI '" + href + "'", ufe); + throw new ResourceException(SR.GetString("InvalidURI", href), ufe); } catch (Exception e) { - throw new ResourceException("Unable to resolve URI reference '" + href + "'", e); + throw new ResourceException(SR.GetString("UnresolvableURI", href), e); } //Check circular inclusion if (_baseURIs.Contains(includeLocation)) @@ -965,13 +976,13 @@ IXmlLineInfo li = _reader as IXmlLineInfo; if (li != null && li.HasLineInfo()) { - throw new SyntaxError("xi:include element cannot be child of xi:include element." - + BaseURI.ToString() - + ", Line " - + li.LineNumber + ", Position " + li.LinePosition); + throw new SyntaxError(SR.GetString("IncludeChildOfIncludeLong", + BaseURI.ToString(), + li.LineNumber, li.LinePosition)); } else - throw new SyntaxError("xi:include element cannot be child of xi:include element."); + throw new SyntaxError(SR.GetString("IncludeChildOfInclude", + BaseURI.ToString())); } if (IsFallbackElement(_reader)) { @@ -982,11 +993,12 @@ if (li != null && li.HasLineInfo()) { //Two xi:fallback - throw new SyntaxError("xi:include element cannot contain more than one xi:fallback element." - + BaseURI.ToString() + ", Line " + li.LineNumber + ", Position " + li.LinePosition); + throw new SyntaxError(SR.GetString("TwoFallbacksLong", + BaseURI.ToString(), + li.LineNumber, li.LinePosition)); } else - throw new SyntaxError("xi:include element cannot contain more than one xi:fallback element."); + throw new SyntaxError(SR.GetString("TwoFallbacks", BaseURI.ToString())); } if (_reader.IsEmptyElement) { @@ -1037,11 +1049,13 @@ IXmlLineInfo li = _reader as IXmlLineInfo; if (li != null && li.HasLineInfo()) { - throw new SyntaxError("xi:include element cannot be child of xi:include element." - + _reader.BaseURI.ToString() + ", Line " + li.LineNumber + ", Position " + li.LinePosition); + throw new SyntaxError(SR.GetString("IncludeChildOfIncludeLong", + _reader.BaseURI.ToString(), + li.LineNumber, li.LinePosition)); } else - throw new SyntaxError("xi:include element cannot be child of xi:include element."); + throw new SyntaxError(SR.GetString("IncludeChildOfInclude", + _reader.BaseURI.ToString())); } if (IsFallbackElement(_reader)) { @@ -1052,11 +1066,12 @@ IXmlLineInfo li = _reader as IXmlLineInfo; if (li != null && li.HasLineInfo()) { - throw new SyntaxError("xi:include element cannot contain more than one xi:fallback element." - + _reader.BaseURI.ToString() + ", Line " + li.LineNumber + ", Position " + li.LinePosition); + throw new SyntaxError(SR.GetString("TwoFallbacksLong", + _reader.BaseURI.ToString(), + li.LineNumber, li.LinePosition)); } else - throw new SyntaxError("xi:include element cannot contain more than one xi:fallback element."); + throw new SyntaxError(SR.GetString("TwoFallbacks", _reader.BaseURI.ToString())); } else { Index: SR.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SR.cs 14 Oct 2004 07:26:13 -0000 1.1 +++ SR.cs 14 Oct 2004 13:47:07 -0000 1.2 @@ -49,13 +49,40 @@ } /// <summary></summary> -// public static string InvalidTokenInElementSchemeWhileNumberExpected -// { -// get -// { -// return SR.GetString("InvalidTokenInElementSchemeWhileNumberExpected"); -// } -// } + public static string AttributeOrNamespaceInIncludeLocationError + { + get + { + return SR.GetString("AttributeOrNamespaceInIncludeLocationError"); + } + } + + /// <summary></summary> + public static string IntradocumentReferencesNotSupported + { + get + { + return SR.GetString("IntradocumentReferencesNotSupported"); + } + } + + /// <summary></summary> + public static string CustomXmlResolverError + { + get + { + return SR.GetString("CustomXmlResolverError"); + } + } + + /// <summary></summary> + public static string CustomXmlResolverReturnedNull + { + get + { + return SR.GetString("CustomXmlResolverError"); + } + } } } Index: SR.resx =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.resx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SR.resx 14 Oct 2004 07:26:13 -0000 1.1 +++ SR.resx 14 Oct 2004 13:47:07 -0000 1.2 @@ -39,7 +39,85 @@ <resheader name="Writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <!-- <data name="InvalidTokenInElementSchemeWhileNumberExpected" type="System.String" mimetype="System.String"> - <value>Syntax error in element() scheme data: Invalid token in ChildSequence, a number was expected.</value> - </data> --> + <data name="NotSupportedEncoding" type="System.String" mimetype="System.String"> + <value>Not supported encoding '{0}'.</value> + </data> + <data name="OutOfMemoryWhileFetchingResource" type="System.String" mimetype="System.String"> + <value>Out of memory error while reading resource '{0}'.</value> + </data> + <data name="IOErrorWhileFetchingResource" type="System.String" mimetype="System.String"> + <value>I/O error while reading resource '{0}'.</value> + </data> + <data name="UnknownParseAttrValue" type="System.String" mimetype="System.String"> + <value>Unknown 'parse' attribute value: '{0}'.</value> + </data> + <data name="UnknownParseAttrValueLong" type="System.String" mimetype="System.String"> + <value>Unknown 'parse' attribute value: '{0}'. In {1}, Line {2}, Position {3}.</value> + </data> + <data name="NonXmlCharacter" type="System.String" mimetype="System.String"> + <value>Included document contains a character not allowed in XML: 0x{0}.</value> + </data> + <data name="CircularInclusion" type="System.String" mimetype="System.String"> + <value>Circular inclusion has been detected, inclusion location: {0}.</value> + </data> + <data name="CircularInclusionLong" type="System.String" mimetype="System.String"> + <value>Circular inclusion has been detected, inclusion location: {0}. In {1}, Line {2}, Position {3}.</value> + </data> + <data name="FatalResourceException" type="System.String" mimetype="System.String"> + <value>Resource error has occured and no fallback has been provided: {0}.</value> + </data> + <data name="AttributeOrNamespaceInIncludeLocationError" type="System.String" mimetype="System.String"> + <value>Include location identifies an attribute or namespace node!</value> + </data> + <data name="FallbackNotChildOfInclude" type="System.String" mimetype="System.String"> + <value>xi:fallback element must be direct child of xi:include element. Location: {0}.</value> + </data> + <data name="FallbackNotChildOfIncludeLong" type="System.String" mimetype="System.String"> + <value>xi:fallback element must be direct child of xi:include element. Location: {0}, Line {1}, Position {2}.</value> + </data> + <data name="URISchemaNotSupported" type="System.String" mimetype="System.String"> + <value>URI schema is not supported: '{0}'.</value> + </data> + <data name="SecurityException" type="System.String" mimetype="System.String"> + <value>Security exception while fetching '{0}'.</value> + </data> + <data name="ResourceError" type="System.String" mimetype="System.String"> + <value>Resource '{0}' cannot be fetched.</value> + </data> + <data name="MissingHrefAndXpointerException" type="System.String" mimetype="System.String"> + <value>'href' or 'xpointer' attributes can't both be omitted on xi:include element. Location: {0}."</value> + </data> + <data name="MissingHrefAndXpointerExceptionLong" type="System.String" mimetype="System.String"> + <value>'href' or 'xpointer' attributes can't both be omitted on xi:include element. Location: {0}, Line {1}, Position {2}.</value> + </data> + <data name="IntradocumentReferencesNotSupported" type="System.String" mimetype="System.String"> + <value>Intra-document references are not supported yet.</value> + </data> + <data name="CustomXmlResolverError" type="System.String" mimetype="System.String"> + <value>An exception has occured during GetEntity call to custom XmlResolver.</value> + </data> + <data name="CustomXmlResolverReturnedNull" type="System.String" mimetype="System.String"> + <value>Custom XmlResolver returned null.</value> + </data> + <data name="CustomXmlResolverReturnedUnsupportedType" type="System.String" mimetype="System.String"> + <value>Custom XmlResolver returned object of an unsupported type '{0}'.</value> + </data> + <data name="InvalidURI" type="System.String" mimetype="System.String"> + <value>Invalid URI '{0}'.</value> + </data> + <data name="UnresolvableURI" type="System.String" mimetype="System.String"> + <value>Unable to resolve URI reference '{0}'.</value> + </data> + <data name="IncludeChildOfInclude" type="System.String" mimetype="System.String"> + <value>xi:include element cannot be child of xi:include element. Location: {0}.</value> + </data> + <data name="IncludeChildOfIncludeLong" type="System.String" mimetype="System.String"> + <value>xi:include element cannot be child of xi:include element. Location: {0}, Line {1}, Position {2}.</value> + </data> + <data name="TwoFallbacks" type="System.String" mimetype="System.String"> + <value>xi:include element cannot contain more than one xi:fallback element. Location: {0}.</value> + </data> + <data name="TwoFallbacksLong" type="System.String" mimetype="System.String"> + <value>xi:include element cannot contain more than one xi:fallback element. Location: {0}, Line {1}, Position {2}.</value> + </data> </root> \ No newline at end of file Index: TextIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/TextIncludingReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TextIncludingReader.cs 29 Sep 2004 21:26:28 -0000 1.2 +++ TextIncludingReader.cs 14 Oct 2004 13:47:07 -0000 1.3 @@ -225,7 +225,7 @@ enc = Encoding.GetEncoding(_encoding); } catch (Exception e) { - throw new ResourceException("Not supported encoding '" + _encoding + "'", e); + throw new ResourceException(SR.GetString("NotSupportedEncoding", _encoding), e); } reader = new StreamReader(stream, enc); } @@ -238,9 +238,9 @@ throw re; } catch (OutOfMemoryException oome) { //Crazy include - memory is out - what about reading by chunks? - throw new ResourceException("Out of memory while reading resource '" + _href + "'", oome); + throw new ResourceException(SR.GetString("OutOfMemoryWhileFetchingResource", _href), oome); } catch (IOException ioe) { - throw new ResourceException("I/O error while fetching '" + _href + "'", ioe); + throw new ResourceException(SR.GetString("IOErrorWhileFetchingResource", _href), ioe); } _state = ReadState.Interactive; return true; @@ -276,7 +276,7 @@ try { return Encoding.GetEncoding(encValue); } catch (Exception e) { - throw new ResourceException("Not supported encoding '" + encValue + "'", e); + throw new ResourceException(SR.GetString("NotSupportedEncoding", encValue), e); } } else //No encoding in XML declaration - UTF-8 by default |